JavaScript Array every()
JavaScript Array every()
The every() method is used to execute a function for each array element. It returns true if the function returns true for all elements. It returns false if the function returns false for one element. It does not execute the function for empty elements and does not change the original array.
Syntax:-
Its syntax is- array.every(function(currentValue, index, arr), thisValue)
Return:-
Its return is:- A boolean i.e, true if all elements pass the test else false.
Further Explanation:-
Parameter | Description |
function() | Required. A function to be run for each element in the array. |
currentValue | Required. The value of the current element. |
index | Optional. The index of the current element. |
arr | Optional. The array of the current element. |
thisValue | Optional. A value is passed to the function as this value. Default is undefined. |