var arr1 = [1,2,3,4,5];
var arr2 = {name:'Join',age:20,address:'XXXXXXXXXXX'}
for(var x in arr1){
console.log(x);
}
结果:
0
1
2
3
4
for(var x in arr2){
console.log("我的key:"+x+",-----我的value:"+arr2[x]);
}
结果:
我的key:name,-----我的value:Join
我的key:age,-----我的value:20
我的key:address,-----我的value:XXXXXXXXXXX