隐式创建
var arr=["Audi","BMW","Volvo"];
直接实例化
var arr=new Array("Audi","BMW","Volvo");
创建数组并给数组元素赋值
var arr=new Array();
arr[0]="Audi";
arr[1]="BMW";
arr[2]="Volvo";
注意:
console.log(arr.length); //
arr[4]='jeep';
console.log(arr.length); //
console.log(arr[3]); //undefined
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)