隱式創建
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); //3 arr[4]='jeep'; console.log(arr.length); //5 console.log(arr[3]); //undefined
