多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
> 循环遍历是一个比较常用的功能,这里特此介绍 [TOC] ## 常规for ~~~ let list = ['wk', 'lj', 'wx']; for (var i = 0; i < list.length; i++) { console.log("index: "+ i + ", val:" + list[i]) } ~~~ ## for in > 循环出来的变量是数组下标 ~~~ let list = ['wk', 'lj', 'wx']; for (let index in list) { console.log("index: "+ index + ", val:" + list[index]) } ~~~ ## for of > 循环出来的变量是数组值 ~~~ let list = ['wk', 'lj', 'wx']; for (let val of list) { console.log(val) } ~~~ ## array.forEach() ~~~ let list = ['wk', 'lj', 'wx']; //list.forEach(function(val, index, arr){ // console.log("index: "+ index + ", val:" + val) //}) list.forEach(function(val){ console.log("val:" + val) }) ~~~