every()
accepts two arguments.
every()
runs the given function on every
item and returns true if the function returns true for every item.
every()
does the query against the array
for matching criteria with the passed in function.
The function passed in receives three arguments.
var numbers = [1,2,3,4,5,4,3,2,1];
var everyResult = numbers.every(function(item, index, array){
return (item > 2);
});
console.log(everyResult); //false
The code above generates the following result.
every() does not change the values contained in the array.