every(): A false is false
. Iterates over the elements of the array. As long as one of the elements is false, it returns false.
const arr = [10, 20, 30, 40]
// 检测数组,是否数组所有元素的值都大于 15
arr.every((item, index) => {
return item > 15
})
some(): true is true,
iterates over the elements of the array, as long as one is true, it returns true
const arr = [10, 20, 30, 40]
// 检测数组,是否数组有哪个元素的值大于 34
arr.some((item, index) => {
return item > 34
})
Just record this, I wish you all a happy!