JavaScript TypedArray find() Method

Beginner
5 min read
Updated: Nov 2026
3 examples
ES2015

Definition

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.

JavaScript
typedArray.find(callbackFn)
typedArray.find(callbackFn, thisArg)
CallWhat it does
ta.find((v) => v > 30)Get the first element greater than 30.
ta.find((v, i, arr) => ...)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

ParameterDescription
callbackFnA 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.
thisArgOptional. The value used as this inside callbackFn (not for arrow functions).

Return Value

Return ValueDescription
Number, BigInt, or undefinedThe 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
Try It Yourself

How It Works

  1. Two values pass, one is returned. Both 31 and 35 are above 30, but find() hands back only 31 because it comes first.
  2. The first element can win. Reading 18 already passes t < 20, so the search ends at index 0.
  3. Tests can combine conditions. The even-and-above-20 test rejects 18, accepts 22, and never even looks at 31, 27, or 35.

Example 2 — undefined and the Zero Trap

Voltages in an Int16Array include a real 0. Checking the result the wrong way would make that zero look like a failed search.

JavaScript
const volts = new Int16Array([0, -5, 12]);

console.log('negative: ' + volts.find((v) => v < 0));    // negative: -5
console.log('huge: ' + volts.find((v) => v > 100));      // huge: undefined

const zero = volts.find((v) => v === 0);
console.log(zero);                                       // 0
console.log(zero ? 'found zero' : 'looks missing');      // looks missing
console.log(zero !== undefined ? 'found zero' : 'missing'); // found zero
Try It Yourself

How It Works

  1. A match returns the number. The test v < 0 matches -5, and that number is joined into the message.
  2. No match returns undefined. No voltage is above 100, so the callback never says yes and find() returns undefined.
  3. Zero is found but falsy. The element 0 was found, yet if (zero) treats it as false. Testing zero !== undefined gives the right answer.

Example 3 — value, index, array, and thisArg

The callback gets three arguments, and an optional second argument to find() sets this. A counter shows that the search stops early.

JavaScript
const samples = new Float32Array([0.5, 1.25, 3.5, 4.75]);
let calls = 0;

const hit = samples.find(function (value, index, array) {
  calls++;
  return value > this.limit && array === samples;
}, { limit: 3 });

console.log(hit);                                      // 3.5
console.log('calls: ' + calls);                        // calls: 3
console.log(typeof hit);                               // number
console.log(samples.find((v) => v > 100) === undefined); // true
Try It Yourself

How It Works

  1. 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.
  2. The limit travels in as this. The regular function reads this.limit, which is 3 because { limit: 3 } was passed as the second argument.
  3. 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.

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 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
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.

Next: findIndex()

Get the position of the first element that passes a test.

findIndex() 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