JavaScript Interview Question #46
What is the difference between some() and every()?
Objects, Arrays & Core Data Handling Junior Beginner
Quick Interview Answer
some returns true when at least one array element satisfies the callback. every returns true only when all elements satisfy it.
Detailed Explanation
some returns true when at least one array element satisfies the callback. every returns true only when all elements satisfy it.
Both methods short-circuit: some can stop after finding a successful match, while every can stop after finding a failing element. This makes them clearer than manually counting matches when the requirement is Boolean.
Code Example
const scores = [75, 82, 91];
const hasExcellent =
scores.some(score => score >= 90);
const allPassed =
scores.every(score => score >= 50);
console.log(hasExcellent); // true
console.log(allPassed); // true