1、every
let arr = [0, 1, 2, 3, 4, 5];
let result = arr.every((item, index) => {
return item >= 0
})
结果: result = true (所有数值都大于或等于0)
let result = arr.every((item, index) => {
return item > 0
})
结果: result = false(不是所有数值都大于0)
2、some
let arr = [0, 1, 2, 3, 4, 5];
let result = arr.some((item, index) => {
return item >= 5
})
结果: result = true(有一些数值大于或等于5)
let arr = [0, 1, 2, 3, 4, 5];
let result = arr.some((item, index) => {
return item > 5
})
结果: result = false(没有数值大于5)