不能使用break打断循环
jquery的要领,不能使用break打断循环,return falsed代表for循环中的break
obj.each(function (i,item) {
// i:循环的下标
// item:循环的节点
// $(this):jquery东西
// $(item):获得要循环的div的单个jquery东西
})
$.each(obj,function (i,item) {
// i:下标
// item:循环的节点东西
// $(this):jquery东西
// $(item):获得要循环的div的单个jquery东西
})
2
forEach要领
只能遍历数组,不能使用break打断循环,return falsed代表for循环中的continue
arr.forEach(function (i,item) {
//arr:循环遍历的数组
// item:数组每一项得值
// i:每一项对应的下标
})
3
for循环
常用于数组的循环遍历 for(let i=0;i<arr.length;i++){ //arr:循环遍历的数组 //arr[i]:数组中该下标的值 }
js中有哪些是循环遍历的要领?
标签:
原文地点:https://www.cnblogs.com/dkjf/p/12275481.html
,温馨提示: 本文由Jm博客推荐,转载请保留链接: https://www.jmwww.net/file/web/30343.html