ES5新增数组方法(3):some

检查数组元素中是否有元素符合指定。

// 数组中的元素部分满足指定条件返回true
let arr = [1, 3, 5, 7, 9];
console.log(arr.some((value, index, array) => value > 10));// false
console.log(arr.some((value, index, array) => value > 8));// true

猜你喜欢

转载自www.cnblogs.com/Jimc/p/10232350.html