数组使用封闭的方括号,并在其中使用逗号分隔值来初始化。一个扁平的 [] 表示空数组,而[1,2,3]用三个元素初始化一个数组。
Arrays are initialized by enclosing comma , separated values in brackets []. A plain [] represents the empty array, whereas [1, 2, 3] initializes an array with three elements 1, 2 and 3.
生成的代码可能在不支持数组初始化的平台不那么简洁。本质上,这样的初始化代码看起来如下:
The generated code may be less concise on platforms that do not support array initialization. Essentially, such initialization code then looks like this:
var a = new Array();
a.push(1);
a.push(2);
a.push(3);
在声明时要考虑这个,是否一个函数应该被内联(第4.4.2节),因为它可能内联进比在可见语法中更多的代码。
This should be considered when deciding if a function should be inlined (4.4.2) as it may inline more code than visible in the syntax.
高级初始化技术在数组推导(第6.6节)中详述。
Advanced initialization techniques are described in Array Comprehension (Section 6.6).