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.
typedarray.includes(searchElement[, fromIndex]);
searchElement
fromIndex
searchElement
; defaults to 0.A Boolean
.
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;
Specification | Status | Comment |
---|---|---|
ECMAScript 2016 (ECMA-262) The definition of 'TypedArray.prototype.includes' in that specification. | Standard | Initial definition. |
ECMAScript 2017 Draft (ECMA-262) The definition of 'TypedArray.prototype.includes' in that specification. | Draft |
Feature | Chrome | Firefox (Gecko) | Edge | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|---|
Basic support | 47 | 43 | 14 | No support | 34 | 10 |
Feature | Android | Chrome for Android | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|---|
Basic support | No support | 47 | 43 | No support | 34 | 10 |
© 2005–2017 Mozilla Developer Network and individual 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