ES5新增数组方法(4):every

检查数组元素的每个元素是否符合条件。

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

猜你喜欢

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