JavaScript-some和every区别
some:有一项匹配则返回true
every:每一项都要匹配
var arr = [1,4,2,10,6]
var result1 = arr.some(val => {return val > 4})
var result2 = arr.every(val => {return val > 4})
console.log(result1)//true
console.log(result2)//false
1
2
3
4
5
6
7
2
3
4
5
6
7
上次更新: 2024/08/14, 04:14:33