iterator.every(callback) walks each value from the iterator and asks your function: does this value pass the test? If every value passes, the result is true. If one value fails, the result is false right away.
The method consumes the iterator. After every() finishes (or stops early), you cannot read more values from that same iterator. Make a new one if you need the values again.
Remember
iterator.every(callback)
callback returns truthy for all → true
callback returns falsy once → false (stops early)
empty iterator → true
Consumes the iterator (it is closed after the call).
Callback gets (value, index).
Syntax
Call it on an iterator and pass a function that returns true or false for each value.
Required. A function called for each value. Return a truthy value to say "this one passes", or a falsy value to say "this one fails". It receives value (the current item) and index (starting at 0).
Return Value
Return Value
Description
boolean
true if every value passed the test, or if the iterator was empty. false as soon as one value fails. The iterator is closed either way.
JavaScript Examples
Example 1 — Check That Every Value Passes
Test whether every number from an iterator is greater than zero.
The Try It page first checks that iterator.every() exists, because Iterator helpers are still new. In an older browser it prints a short explanation and the output above. In a current browser it runs the code for real.
How It Works
Make an iterator.[1, 2, 3, 4, 5].values() yields each number one by one.
Test every value. The callback (n) => n > 0 returns true for 1, 2, 3, 4, and 5.
Read the result. Because nothing failed, every() returns true.
Example 2 — Stop When One Value Fails
See that every() returns false as soon as one value does not pass the test.
The Try It page first checks that iterator.every() exists, because Iterator helpers are still new. In an older browser it prints a short explanation and the output above. In a current browser it runs the code for real.
How It Works
Start checking. 2 and 4 are even, so they pass.
Hit a failure. 5 is odd, so the callback returns falsy and every() stops.
Result is false. The later value 8 is never tested, and the iterator is closed.
Example 3 — See That the Iterator Is Used Up
After every() runs, calling next() on the same iterator shows it is already done.
JavaScript
const nums = [1, 2, 3].values();
const ok = nums.every((n) => n < 10);
const after = nums.next();
console.log("every result: " + ok);
console.log("done after: " + after.done);
The Try It page first checks that iterator.every() exists, because Iterator helpers are still new. In an older browser it prints a short explanation and the output above. In a current browser it runs the code for real.
How It Works
Run every(). All three values are less than 10, so the result is true.
Iterator finished. Because every value was read, the iterator has nothing left.
Check next().after.done is true, so there are no values left to read.
Compatibility
Browser & Runtime Support
Iterator.prototype.every() is an Iterator helper (Baseline Newly available since March 2025). It works in current browsers and in Node.js 22 or newer.
✓ Baseline 2025 · Newly available
iterator.every()
Supported in Chrome 122+, Edge 122+, Firefox 131+, Safari 18.4+, Opera 108+ and Node.js 22+. Internet Explorer never got it.
2025Standard since
Google Chrome122+ · Desktop & Mobile
Full support
Microsoft Edge122+ · Chromium based
Full support
Mozilla Firefox131+ · Desktop & Mobile
Full support
Apple Safari18.4+ · macOS & iOS
Full support
Opera108+ · Chromium based
Full support
Samsung Internet26+ · Android
Supported
Android WebView122+ · Chromium based
Supported
Node.js22+ · Server runtime
Supported
DenoRecent versions · JavaScript runtime
Supported
BunRecent versions · JavaScript runtime
Supported
Internet ExplorerNo native support
Not supported
iterator.every()Current browsers
Bottom line: Check support with a typeof test before you use it in older browsers. Prefer chaining helpers and calling toArray() last.
Frequently Asked Questions
It tests each value from an iterator with your callback. If every value passes, it returns true. If one fails, it returns false and stops. The iterator is consumed either way.
Yes. An empty iterator returns true, because there was no value that failed the test. The same idea exists for Array.prototype.every().
No. every() closes the iterator. Create a new one (for example call .values() again) if you need the values once more.
Two: the current value and its zero-based index. Return any truthy value to pass, or any falsy value to fail.
The idea is the same, but it runs on an iterator instead of an array. It is part of the Iterator helpers, so check support in older browsers with a typeof test.