typedArray.find(callback) walks through the elements from the first to the last and returns the first element for which your callback returns a truthy value. It stops there and ignores the rest. If no element passes, it returns undefined. The returned value is a plain number (or BigInt), not a typed array. It is handy for searching typed data such as sensor readings or pixel values.
Remember
typedArray.find((value, index, array) => test)
new Uint8Array([18, 22, 31]).find(t => t > 20) โ 22
new Uint8Array([18, 22, 31]).find(t => t > 99) โ undefined
first match wins ยท returns the VALUE
need the position? use findIndex()
Syntax
find() takes a callback and an optional thisArg. Call it on any typed array.
The callback also receives the index and the typed array itself.
ta.find(function (v) { ... }, obj)
Use obj as this inside a regular function.
Built into JavaScript since ES2015 on all 11 typed array types. The callback is called once per element, in order, until one returns a truthy value.
Library declarations
JavaScript
TypedArray.prototype.find(callbackFn, thisArg)
// callbackFn(value, index, array) -> truthy: this element is the answer
// returns the element, or undefined if none passed
Parameters
Parameter
Description
callbackFn
A function called as (value, index, array). value is the current element, index its position, and array the typed array. Return a truthy value to pick the element.
thisArg
Optional. The value used as this inside callbackFn (not for arrow functions).
Return Value
Return Value
Description
Number, BigInt, or undefined
The first element that passed the test, or undefined if none did. Regular arrays work the same way: see Array find().
JavaScript Examples
Example 1 — Find the First Hot Reading
A weather station stores five temperatures in a Uint8Array. We look for the first one that fits a test.
JavaScript
const temps = new Uint8Array([18, 22, 31, 27, 35]);
console.log(temps.find((t) => t > 30)); // 31
console.log(temps.find((t) => t < 20)); // 18
console.log(temps.find((t) => t % 2 === 0 && t > 20)); // 22
The third argument is the typed array. Inside the callback, array === samples is true, so you can read neighbours with array[index - 1] if needed.
The limit travels in as this. The regular function reads this.limit, which is 3 because { limit: 3 } was passed as the second argument.
Three calls, not four. The callback ran for 0.5, 1.25, and 3.5. At 3.5 it said yes, so 4.75 was never visited. The answer is a plain number.
Compatibility
Browser & Runtime Support
TypedArray.prototype.find() arrived with typed arrays and Array.prototype.find() in ES2015 (ES6).
✓ Baseline · ES2015
TypedArray.prototype.find()
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
find()Excellent
Bottom line: Safe everywhere modern JavaScript runs. Only Internet Explorer is missing it: IE 10 and 11 have typed arrays, but not this method.
Frequently Asked Questions
The first element that passes your test, as a plain number or BigInt. If nothing passes, it returns undefined.
find() returns the element value, while findIndex() returns its position, or -1 if there is none. Pick findIndex() when you need to change that element afterwards.
No. filter() returns a new typed array of all matches. find() returns only one value, the first match.
Yes. The callback is not called for the elements after the first match, so a long typed array is not scanned for nothing.
Use findLast(), which searches from the end. It is part of ES2023, so it needs a recent browser.