JavaScript Iterator every()
Example
Check if all values are over 7:
function checkValue(value) {
return value > 7;
}
const myIterator = Iterator.from("123456789");
let result = myIterator.every(checkValue);
Try it Yourself »
Description
The every()
method executes a function for each array element.
The every()
method returns true
if the function returns true for all elements.
The every()
method returns false
if the function returns false for one element.
The every()
method does not execute the function for empty elements.
The every()
method does not change the original iterator.
Syntax
iterator.every(function(currentValue, index, arr), thisValue)
Parameters
Parameter | Description |
function() | Required. A function to be run for each element in the iterator. |
currentValue | Required. The value of the current element. |
index | Optional. The index of the current element. |
arr | Optional. The iterator of the current element. |
thisValue | Optional. Default undefined .A value passed to the function as its this value. |
Return Value
Type | Description |
Boolean |
true if all elements pass the test, otherwise false . |
Browser Support
interator.every()
is an ES2025 feature.
ES2025 is fully supported in all modern browsers since May 2025:
Chrome 135 | Edge 135 | Firefox 129 | Safari 18.2 | Opera 120 |
Apr 2025 | Apr 2025 | Aug 2024 | Des 2024 | May 2025 |