TypedArray.prototype.includes()

The includes() method determines whether a typed array includes a certain element, returning true or false as appropriate. This method has the same algorithm as Array.prototype.includes(). TypedArray is one of the typed array types here.

Syntax

typedarray.includes(searchElement[, fromIndex]);

Parameters

searchElement
The element to search for.
fromIndex
Optional. The position in this array at which to begin searching for searchElement; defaults to 0.

Return value

A Boolean.

Examples

var uint8 = new Uint8Array([1,2,3]);
uint8.includes(2);     // true
uint8.includes(4);     // false
uint8.includes(3, 3);  // false

// NaN handling (only true for Float32 and Float64)
new Uint8Array([NaN]).includes(NaN); // false, since the NaN passed to the constructor gets converted to 0
new Float32Array([NaN]).includes(NaN); // true;
new Float64Array([NaN]).includes(NaN); // true;

Specifications

Specification Status Comment
ECMAScript 2016 (ECMA-262)
The definition of 'TypedArray.prototype.includes' in that specification.
Standard Initial definition.
ECMAScript Latest Draft (ECMA-262)
The definition of 'TypedArray.prototype.includes' in that specification.
Draft  

Browser compatibility

Update compatibility data on GitHub
DesktopMobileServer
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidEdge MobileFirefox for AndroidOpera for AndroidiOS SafariSamsung InternetNode.js
Basic supportChrome Full support 47Edge Full support 14Firefox Full support 43IE No support NoOpera Full support 34Safari Full support 10WebView Android No support NoChrome Android Full support 47Edge Mobile ? Firefox Android Full support 43Opera Android Full support 34Safari iOS Full support 10Samsung Internet Android Full support 5.0nodejs Full support 6.0.0
Full support 6.0.0
Full support 5.0.0
Disabled
Disabled From version 5.0.0: this feature is behind the --harmony runtime flag.

Legend

Full support  
Full support
No support  
No support
Compatibility unknown  
Compatibility unknown
User must explicitly enable this feature.
User must explicitly enable this feature.

See also

Document Tags and Contributors

Last updated by: wbamberg,