Array.Every()
Array.Every() method checks whether all the elements in a given array passes the test implemented by the provided function(function given by user). It executes true when all the elements have passed the test and it executes false even one element in an array failed the test.In the following example every() method checks whether the given salary elements have crossed the given salary limit(10000) and executes Boolean(true, false) output.
Example
<html> <body> <p id="every1"></p> <p id="every2"></p> <script> var wages = [15000, 33000, 19000, 54000]; var salary = [9000,33000,19000,54000]; function checkSal(wage) { return wage >= 10000; } document.getElementById("every1").innerHTML = wages.every(checkSal); document.getElementById("every2").innerHTML = salary.every(checkSal); </script> </body> </html>
output
true false