
上QQ阅读APP看书,第一时间看更新
Iterating using the every method
The first method we will take a look at is the every method. The every method iterates each element of the array until the function returns false, as follows:
numbers.every(isEven);
In this case, our first element of the numbers array is the number 1. 1 is not a multiple of 2 (it is an odd number), so the isEven function will return false, and this will be the only time the function will be executed.