In ES5 there were added a number of new Array methods, including Array.prototype.every(). With this method you can check all the items inside an array for a condition that's defined in a callback function.

The method will return true if all items meet the conditions, but will return false as soon as it finds one item in the array that doesn't meet the specified condition.

Here we have two numeric arrays defined. We log our every() method call for each of the arrays. Notice the function that's passed as an argument into every(). That's the function that defines our condition to be met.

In this case, we're checking to ensure all the numbers in the array are even numbers, using the modulus operator (%). As shown in the trailing comment for each log, the first array passes the test, but the second one doesn't (it has a "5" in it).

As you can see, this is a very simple way to loop through all the items for a specific check, without incorporating too much complex logic.