The every()
method of TypedArray
instances tests whether all elements in the typed array pass the test implemented by the provided function. It returns a Boolean value. This method has the same algorithm as Array.prototype.every()
.
The every()
method of TypedArray
instances tests whether all elements in the typed array pass the test implemented by the provided function. It returns a Boolean value. This method has the same algorithm as Array.prototype.every()
.
every(callbackFn) every(callbackFn, thisArg)
callbackFn
A function to execute for each element in the typed array. It should return a truthy value to indicate the element passes the test, and a falsy value otherwise. The function is called with the following arguments:
thisArg
Optional
A value to use as this
when executing callbackFn
. See iterative methods.
true
unless callbackFn
returns a falsy value for a typed array element, in which case false
is immediately returned.
See Array.prototype.every()
for more details. This method is not generic and can only be called on typed array instances.
The following example tests whether all elements in the typed array are 10 or bigger.
function isBigEnough(element, index, array) { return element >= 10; } new Uint8Array([12, 5, 8, 130, 44]).every(isBigEnough); // false new Uint8Array([12, 54, 18, 130, 44]).every(isBigEnough); // true
Desktop | Mobile | Server | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | WebView Android | Deno | Node.js | ||
every |
45 | 12 | 37 | 32 | 9.1 | 45 | 37 | 32 | 9.3 | 5.0 | 45 | 1.0 | 4.0.0 |
© 2005–2023 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/every