Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/441.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 赞成/反对在一个对象中包含大多数数据_Javascript_Performance - Fatal编程技术网

Javascript 赞成/反对在一个对象中包含大多数数据

Javascript 赞成/反对在一个对象中包含大多数数据,javascript,performance,Javascript,Performance,我有一个web应用程序,它有几个highcharts、几个数据表以及与所有这些一起使用的配置设置。目前我通过多个变量引用它们。 像这样: var charts = {};//associative array of HighCharts var tableInit = {};//table legend and other initialization data, also includes references to tables var cache = {};//associative ar

我有一个web应用程序,它有几个highcharts、几个数据表以及与所有这些一起使用的配置设置。目前我通过多个变量引用它们。 像这样:

var charts = {};//associative array of HighCharts
var tableInit = {};//table legend and other initialization data, also includes references to tables
var cache = {};//associative array of Table Cache
这样做是好还是坏

var data_store = {
    'tableInit' : {},//table legend and other initialization data
    'category' : {
        '-1' : {
            'chart' : $reference_to_Highchart,
            'table' : $reference_to_DataTable,
            'cache' : {}//object to store DataTable cache
        }
    }
}

通常没什么大不了的。我的意思是,我一直在处理非常大的json对象,而且我在这方面没有任何问题。但是,您可能希望将数据分成不同的对象,以使事情更易于管理。除此之外,大多数现代JS引擎(如V8和OdinMonkey)处理对象的速度都非常快


有时,它可能会使全局名称空间变得混乱,但如果您在IFFE中执行所有操作,那么您真的不应该有任何问题。

全局变量越少越好。我想说的是,除了整合,您没有弄乱全局名称空间,这会阻止覆盖来自其他devs\libraries的名称。我还必须支持返回IE7,因此,如果以这种或那种方式进行比较快,我需要这样做。