typedArray.some(callback) checks whether at least one element of a typed array passes a test. It calls your predicate in index order and returns true at the first element where the callback returns a truthy value. If no element passes, it returns false. It does not change the typed array, and on an empty typed array it always returns false.
Remember
typedArray.some(callback, thisArg) → true or false
callback(value, index, array)
first element that passes → true (stops there)
no element passes → false
empty typed array → false
new Int16Array([5, -2]).some((v) => v < 0) → true
Syntax
Pass a predicate function. The second argument thisArg is optional.
One negative is enough. The element -3 passes v < 0, so the first question is answered with true.
No reading is above 100. All four readings fail v > 100, so after testing them all the method returns false.
Empty means no match. An empty typed array has no element to match, so even a callback that always returns true is never called and the result is false.
Example 2 — Look for NaN and Stop Early
A Float32Array may hold NaN when a sensor fails. We search for it and count how many elements were tested.
JavaScript
const samples = new Float32Array([1.5, 2.5, NaN, 4.5]);
let calls = 0;
const bad = samples.some((v) => {
calls++;
return Number.isNaN(v);
});
console.log(bad); // true
console.log('stopped after ' + calls + ' calls'); // stopped after 3 calls
console.log(samples.some(Number.isNaN)); // true
Compare each byte with its left neighbour. At index 1 the check arr[i - 1] === v finds 7 next to 7, so some() returns true without testing the rest.
A different this each call. The first call passes { code: 9 } and finds the byte 9 at index 2.
A code that is not stored. With { code: 200 } no byte matches, so every element is tested and the answer is false.
Compatibility
Browser & Runtime Support
TypedArray.prototype.some() is part of ES2015 (ES6), together with the other array-like methods of typed arrays.
✓ Baseline · ES2015
TypedArray.prototype.some()
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
some()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 as soon as the callback returns a truthy value for one element, and false if no element passes the test.
It always returns false, because there is no element that could pass. The callback is never called. Its partner every() returns true for an empty typed array.
Use ta.some(Number.isNaN). The test v === NaN never works, because NaN is not equal to anything. The includes(NaN) method also finds it on float arrays.
Use includes() when you look for one exact value. Use some() when the test is a rule, such as "any number below zero" or "any byte above 200".
No. It only reads the elements. The typed array keeps its length, its values, and its buffer, whether the answer is true or false.