js的数组申明
1 //数组的3种申明方法,如下example 2 //数组是一种object类型 通过typeof 来检查
3 4 //example 1 5 var arr= new Array("h","k","M","c"); 6 7 console.log(typeof arr);//object 8 for( var i in arr){ 9 console.log(arr[i]); 10 } 11 12 13 14 //example 2 15 var arr1=Array("hello","你好","大海"); 16 console.log(typeof arr1);//object 17 for( var i in arr1){ 18 console.log(arr1[i]); 19 } 20 21 22 //example 3 23 var arr3=["hello","你好","大海"]; 24 console.log(typeof arr3);//object 25 for(var i in arr3){ 26 console.log(arr3[i]); 27 } 28 29 //example 二维数组 30 var arr4=["hello","你好","大海"] 31 arr4[0]=['这是哪里']; 32 33 console.log(arr4[0][0]);