What is the every() method in JavaScript?

The every() method checks if all the elements in an array pass a test; the test is passed to the method as a function. The method returns true if all the elements pass the test, and false if otherwise.

The function returns false immediately after encountering the first element that fails the condition.

Syntax

The syntax is shown​ below:

svg viewer

Code

function isPositive(element) {
return element >= 0;
}
let arr = [1, 4, 82, 45, 6]
console.log(arr.every(isPositive));
let arr = [11, 12, 13, 14, 15]
console.log(arr.every(element => element > 10));
function isCanine(element, index, arr) {
console.log("Checking if " + arr[index] + " is a canine.")
return (element == "dog" || element == "doggo")
}
let arr = ["dog", "cat", "doggo"]
console.log(arr.every(isCanine));
New on Educative
Learn to Code
Learn any Language as a beginner
Develop a human edge in an AI powered world and learn to code with AI from our beginner friendly catalog
🏆 Leaderboard
Daily Coding Challenge
Solve a new coding challenge every day and climb the leaderboard

Free Resources

Copyright ©2025 Educative, Inc. All rights reserved