JavaScript TypedArray every() Method

Beginner
5 min read
Updated: Nov 2026
3 examples
ES2015

Definition

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.

JavaScript
typedArray.every(callback)
typedArray.every(callback, thisArg)
CallWhat it does
ta.every((v) => v > 0)Test every element with an arrow function.
ta.every((v, i, arr) => ...)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

ParameterDescription
callbackA function called once per element with (value, index, array). Return a truthy value when the element passes.
thisArgOptional. The value used as this inside the callback. Arrow functions ignore it.

Return Value

Return ValueDescription
Booleantrue 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
Try It Yourself

How It Works

  1. Every reading is at most 100. The first predicate v <= 100 is true for 40, 72, 95, and 60, so every() gives true.
  2. One weak reading is enough to fail. The reading 40 is not above 50, so the second question returns false as soon as that element is tested.
  3. Nothing to fail means true. The empty typed array has no element that could fail the impossible test v > 1000, so the answer is still true.

Example 2 — It Stops at the First Failure

Daily temperatures sit in an Int16Array. The test counts how many times it runs, which shows that every() quits early.

JavaScript
const temps = new Int16Array([20, 22, -4, 25, 30]);
let calls = 0;

const allWarm = temps.every((t) => {
  calls++;
  return t >= 0;
});

console.log(allWarm);                             // false
console.log('callback ran ' + calls + ' times');  // callback ran 3 times
console.log(temps.length);                        // 5
Try It Yourself

How It Works

  1. A counter inside the callback. Each time the predicate runs, calls++ adds one, so the final value tells us how many elements were really looked at.
  2. The third element ends the walk. The value -4 at index 2 fails t >= 0. every() returns false and never reads 25 or 30.
  3. The typed array is untouched. All five temperatures are still stored; the early exit only skipped the checking, not the data.

Example 3 — Use the Index, the Array, and thisArg

The predicate can look at neighbours through arr, and a regular function can read a limit from thisArg.

JavaScript
const steps = new Int32Array([10, 20, 30, 45]);

const rising = steps.every((v, i, arr) => i === 0 || arr[i - 1] <= v);
console.log(rising);  // true

function belowMax(v) {
  return v <= this.max;
}
console.log(steps.every(belowMax, { max: 50 }));  // true
console.log(steps.every(belowMax, { max: 40 }));  // false
Try It Yourself

How It Works

  1. 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.
  2. A limit travels in thisArg. The object { max: 50 } is passed as the second argument, so this.max inside belowMax reads 50.
  3. A smaller limit changes the answer. With { max: 40 } the last element 45 fails, so the same function returns false.

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 Chrome All modern versions
Full support
Mozilla Firefox All modern versions
Full support
Apple Safari All modern versions
Full support
Microsoft Edge All modern versions
Full support
Node.js All current releases
Supported
Deno All releases
Supported
Internet Explorer IE 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.

Next: fill()

Fill all or part of a typed array with one value, from a start index to an end index.

fill() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

11 people found this page helpful