分类:for
本文实例讲述了js中forEach,forin,forof循环的用法。分享给大家供大家参考,具体如下:一、一般的遍历数组的方法:vararray=[1,2,3,4,5,6,7];for(vari=0;i<array.length;i++){console.log(i,array[i]);}二、用forin的方遍历数组,得到的是索引vararray=[1,2,3,4,5,6,7];for(letindexinarray){console.log(index,array[index]);};三、forEach,得到的是元素vararray=[1,2,3,4,5,6,7];array.forEach(e...
继续阅读 >
2015
06-16