我有一个函数,其中定义了很多变量和非常大的数组;这使得函数非常大并且难以使用。如何在另一个文件中定义变量/数组并在此函数中使用它们?
例子:
DoStuff.js:
function genList(){
var listData = [
//lots of inner arrays and data
]
var dataItem = "value";//50 of these
//do stuff with the data
}
我正在尝试做的事情:
外部数据.js:
var listData = [
//lots of inner arrays and data
]
var dataItem = "value";//50 of these
DoStuff.js:
function genList(){
//call variables/arrays from ExternalData.js
//do stuff
}
注意: JQuery 在这里适用,但我宁愿不为这么小的东西调用任何其他库。