var arr1 = [];
arr1[0] = 1;
arr1[1] = 2;
arr1[2] = 3;
console.log(arr1.length);
//输出结果:3
var arr2 = [];
arr2[0] = 1;
arr2[1] = 2;
arr2.foo = 3;
console.log(arr2.length);
//输出结果:2
var arr3 = [];
arr3.first = 1;
arr3.second = 2;
arr3.third = 3;
console.log(arr3.length);
//输出结果:0