| [ Web Proxy ] |
| Viewing: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/some | [Back] [Original] |
Get to know MDN better
This feature is well established and works across many devices and browser versions. Its been available across browsers since September 2016.
The some() method of TypedArray instances returns true if it finds an element in the array that satisfies the provided testing function. Otherwise, it returns false. This method has the same algorithm as Array.prototype.some().
function isNegative(element, index, array) {
return element < 0;
}
const int8 = new Int8Array([-10, 20, -30, 40, -50]);
const positives = new Int8Array([10, 20, 30, 40, 50]);
console.log(int8.some(isNegative));
// Expected output: true
console.log(positives.some(isNegative));
// Expected output: false
some(callbackFn)
some(callbackFn, thisArg)
callbackFnA 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 OptionalA value to use as this when executing callbackFn. See iterative methods.
false unless callbackFn returns a truthy value for a typed array element, in which case true is immediately returned.
See Array.prototype.some() for more details. This method is not generic and can only be called on typed array instances.
The following example tests whether any element in the typed array is bigger than 10.
function isBiggerThan10(element, index, array) {
return element > 10;
}
new Uint8Array([2, 5, 8, 1, 4]).some(isBiggerThan10); // false
new Uint8Array([12, 5, 8, 1, 4]).some(isBiggerThan10); // true
| Specification |
|---|
| ECMAScript 2027 LanguageSpecification # sec-%typedarray%.prototype.some |
TypedArray.prototype.some in core-jsTypedArrayTypedArray.prototype.every()TypedArray.prototype.forEach()TypedArray.prototype.find()TypedArray.prototype.includes()Array.prototype.some()This page was last modified on Feb 24, 2026 by MDN contributors.
TypedArrayObject/FunctionBigInt64ArrayBigUint64ArrayFloat16ArrayFloat32ArrayFloat64ArrayInt8ArrayInt16ArrayInt32ArrayUint8ArrayUint8ClampedArrayUint16ArrayUint32ArrayYour blueprint for a better internet.
Portions of this content are 19982026 by individual mozilla.org contributors. Content available under a Creative Commons license.
| Web Proxy Viewer | New URL | Original Page |