Put anything into an array using Array.push().
(使用Array.push()将任何东西放入数组。)
var a=[], b={};
a.push(b);
// a[0] === b;
Extra information on Arrays
(有关数组的更多信息)
Add more than one item at a time
(一次添加多个项目)
var x = ['a'];
x.push('b', 'c');
// x = ['a', 'b', 'c']
Add items to the beginning of an array
(将项目添加到数组的开头)
var x = ['c', 'd'];
x.unshift('a', 'b');
// x = ['a', 'b', 'c', 'd']
Add the contents of one array to another
(将一个数组的内容添加到另一个数组)
var x = ['a', 'b', 'c'];
var y = ['d', 'e', 'f'];
x.push.apply(x, y);
// x = ['a', 'b', 'c', 'd', 'e', 'f']
// y = ['d', 'e', 'f'] (remains unchanged)
Create a new array from the contents of two arrays
(从两个数组的内容创建一个新数组)
var x = ['a', 'b', 'c'];
var y = ['d', 'e', 'f'];
var z = x.concat(y);
// x = ['a', 'b', 'c'] (remains unchanged)
// y = ['d', 'e', 'f'] (remains unchanged)
// z = ['a', 'b', 'c', 'd', 'e', 'f']