JavaScript Iterator some()
Example
Check if any values are over 7:
function checkValue(value) {
return value > 7;
}
const myIterator = Iterator.from("123456789");
let result = myIterator.some(checkValue);
Try it Yourself »
Description
The some()
method checks if any element pass a test provided by a callback function.
The some()
method executes the callback function once for each element.
The some()
method returns true
(and stops)
if the function returns true
for one of the array elements.
The some()
method returns false
if the function returns false
for all of the array elements.
The some()
method does not execute the function for empty elements.
The some()
method does not change the original iterator.
Syntax
iterator.some(function(value, index, arr), this)
Parameters
Parameter | Description | ||||||
function | Required. A function to run for each element. |
||||||
Function parameters:
|
|||||||
this | Optional. Default undefined .A value passed to the function to be used as its "this" value. |
Return Value
Type | Description |
A boolean |
true if any element pass the test, otherwise false . |
Browser Support
iterator.some()()
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 |