VOOZH about

URL: https://www.geeksforgeeks.org/javascript/javascript-array-every-method/

⇱ JavaScript Array every() Method - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

JavaScript Array every() Method

Last Updated : 1 Jun, 2026

The every() method iterates over each array element, returning true if the provided function returns true for all elements. It returns false if the function returns false for any element. This method does not operate on empty elements and leaves the original array unchanged.

Syntax

array.every(callback(element, index, array), thisArg);

Parameters

  • callback: A function to test each element of the array. It takes three arguments:
    • element: The current element being processed in the array.
    • index (optional): The index of the current element being processed.
    • array (optional): The array every() was called upon.
  • thisArg (optional): An object to use this when executing the callback function.

Return value

This method returns a Boolean value true if all the elements of the array follow the condition implemented by the argument method. If any one of the elements of the array does not satisfy the argument method, then this method returns false.

Example 1: This example demonstrates the usage of the every() method on an array to check if every element satisfies a condition defined by the isEven callback function.

Example 2: This example showcases the utilization of the every() method on an array to verify if all elements meet a condition set by the `isPositive` callback, returning true since all elements are positive.

Example 3: Here, we will check whether one array is exactly the subset of another array or not using several methods like every() as well as includes().

We have a complete list of Javascript Array methods, to check those please go through this Javascript Array Complete reference article.

Comment