This feature is well established and works across many devices and browser versions. It’s been available across browsers since September 2016.
The includes() method of TypedArray instances determines whether a typed array includes a certain value among its entries, returning true or false as appropriate. This method has the same algorithm as Array.prototype.includes().
const uint8 = new Uint8Array([10, 20, 30, 40, 50]); console.log(uint8.includes(20)); // Expected output: true // Check from position 3 console.log(uint8.includes(20, 3)); // Expected output: false
includes(searchElement) includes(searchElement, fromIndex)
searchElementThe value to search for.
fromIndex OptionalZero-based index at which to start searching, converted to an integer.
A boolean value which is true if the value searchElement is found within the typed array (or the part of the typed array indicated by the index fromIndex, if specified).
See Array.prototype.includes() for more details. This method is not generic and can only be called on typed array instances.
const uint8 = new Uint8Array([1, 2, 3]); uint8.includes(2); // true uint8.includes(4); // false uint8.includes(3, 3); // false // NaN handling (only relevant for floating point arrays) new Uint8Array([NaN]).includes(NaN); // false, since the NaN passed to the constructor gets converted to 0 new Float32Array([NaN]).includes(NaN); // true
| Desktop | Mobile | Server | |||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | WebView Android | WebView on iOS | Bun | Deno | Node.js | |
includes |
47 | 14 | 43 | 34 | 10 | 47 | 43 | 34 | 10 | 5.0 | 47 | 10 | 1.0.0 | 1.0 | 6.0.0 |
© 2005–2025 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/includes