
上QQ阅读APP看书,第一时间看更新
Iterating using the some method
Next, we have the some method. It has the opposite behavior to the every method; however, the some method iterates each element of the array until the return of the function is true:
numbers.some(isEven);
In our case, the first even number of our numbers array is 2 (the second element). The first element that will be iterated is the number 1; it will return false. Then, the second element that will be iterated is the number 2, which will return true, and the iteration will stop.