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 »
const myIterator = Iterator.from("123456789");
// Is every element greater than 7 ?
let result = myIterator.every(x => x > 7);
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.
A function to be run for each element in the iterator.
currentValue
Required.
The value of the current element.
The value of the current element.
index
Optional.
The index of the current element.
The index of the current element.
arr
Optional.
The iterator of the current element.
The iterator of the current element.
thisValue
Optional. Default
A value passed to the function as its
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 a JavaScript 2025 feature.
ES 2025 is fully supported in all modern browsers since May 2025:
Chrome 136 |
Edge 136 |
Firefox 129 |
Safari 18.2 |
Opera 120 |
Apr 2025 | Apr 2025 | Aug 2024 | Des 2024 | May 2025 |