typedArray.every(callback) checks whether all elements of a typed array pass a test. It calls your predicate for each element, in index order, and returns true only if every call returns a truthy value. It stops at the first element that fails and returns false right away. It never changes the typed array, and on an empty typed array it returns true, because no element can fail.
Remember
typedArray.every(callback, thisArg) → true or false
callback(value, index, array)
every element passes → true
first failure → false (stops there)
empty typed array → true
new Uint8Array([40, 72]).every((v) => v < 100) → true
Syntax
Pass a predicate function. The second argument thisArg is optional.
The predicate also receives the index and the typed array itself.
ta.every(function (v) { ... }, obj)
Set this inside a regular function with the optional thisArg.
Built into JavaScript since ES2015 on all 11 typed array types, from Int8Array to BigUint64Array. On a BigInt array the callback receives BigInt values.
Library declarations
JavaScript
TypedArray.prototype.every(callbackFn, thisArg?) // returns a boolean
// callbackFn(value, index, array) -> any value, read as true or false
// empty typed array -> true
Parameters
Parameter
Description
callback
A function called once per element with (value, index, array). Return a truthy value when the element passes.
thisArg
Optional. The value used as this inside the callback. Arrow functions ignore it.
Return Value
Return Value
Description
Boolean
true if the callback returned a truthy value for every element (or the typed array is empty), otherwise false. It is never a typed array.
JavaScript Examples
Example 1 — Test Whether All Readings Pass
A Uint8Array holds four volume readings. We ask two yes-or-no questions about all of them, then try an empty typed array.
JavaScript
const levels = new Uint8Array([40, 72, 95, 60]);
console.log(levels.every((v) => v <= 100)); // true
console.log(levels.every((v) => v > 50)); // false
const none = new Uint8Array(0);
console.log(none.every((v) => v > 1000)); // true
Compare with the previous element. For index 1 and up, arr[i - 1] <= v checks that the numbers never go down. Index 0 has no neighbour, so it passes automatically.
A limit travels in thisArg. The object { max: 50 } is passed as the second argument, so this.max inside belowMax reads 50.
A smaller limit changes the answer. With { max: 40 } the last element 45 fails, so the same function returns false.
Compatibility
Browser & Runtime Support
TypedArray.prototype.every() is part of ES2015 (ES6), the edition that introduced typed array methods like the ones on regular arrays.
✓ Baseline · ES2015
TypedArray.prototype.every()
Supported in every modern browser, plus Node.js, Deno, and Bun.
98%Modern browser support
Google ChromeAll modern versions
Full support
Mozilla FirefoxAll modern versions
Full support
Apple SafariAll modern versions
Full support
Microsoft EdgeAll modern versions
Full support
Node.jsAll current releases
Supported
DenoAll releases
Supported
Internet ExplorerIE 10 and 11 have typed arrays, but not this method
Not supported
every()Excellent
Bottom line: Safe everywhere modern JavaScript runs. Internet Explorer 10 and 11 have typed arrays but not this method, so there you would use a plain for loop.
Frequently Asked Questions
A boolean. It is true when the callback returns a truthy value for every element, and false as soon as one element fails the test.
It returns true. With no elements there is nothing that can fail, so the statement "all elements pass" is true. Its partner some() returns false in the same case.
Yes. After the first element that makes the callback return a falsy value, every() returns false and skips the rest of the elements.
Arrow functions keep the this value of the place where they were written, so they ignore thisArg. Use a regular function if you need this inside the callback.
The answer is the same, but every() is faster and simpler. It builds no new typed array and stops at the first failure instead of testing all elements.