数组迭代的一些方法
时间:2020-04-20 09:34:13
收藏:0
阅读:60
- for循环--最普通的方法
- arr.forEach(function(value, index, array){})--遍历数组-----map()相似
- arr.filter(function(value, index, array){ return value > 20;})--筛选数组--返回的是一个新的数组
- arr.some(function(val, index, arr){ return value > 20;})--查找是否没有满足条件的元素,返回布尔值---查找到第一个符合条件的元素,则停止循环-----every()相似
原文:https://www.cnblogs.com/joeynkay/p/12735335.html
评论(0)