JavaScript Iterator every()
Example
Check if all values are over 7:
// Create an Iterator
const myIterator = Iterator.from("123456789");
// Is every element greater than 7 ?
let result = myIterator.every(x => x > 7);
Try it Yourself »
Description
The every()
method returns true
if all elements satisfy a provided test function.
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.
JavaScript 2025 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 |