标签:bsp nbsp -- app 使用 its rip for循环 深圳
一维数组
var fruits = ["apple","banana","pear"];
二维数组
var arr2 = new Array(); arr2["湖南"] = ["长沙","湘潭","株洲"]; arr2["广东"] = ["广州","深圳","珠海"]; document.write(arr2.length + "<br>"); //arr2.length = 0 document.write(arr2["湖南"].length + "<br>"); for(var i in arr2){ document.write("<h4>" + i + "</h4>"); for(var j in arr2[i]){ document.write(arr2[i][j] + " "); } }
字符串也可以做数组的索引,但是就不能使用for循环了,只可以用for-each循环。
标签:bsp nbsp -- app 使用 its rip for循环 深圳
原文地址:https://www.cnblogs.com/skyline1/p/12168444.html