The Javascript Uint32Array includes()
method checks whether a typed array includes a certain element.
It returns true or false.
This method works the same as Array.prototype.includes()
.
Uint32Array.includes(searchElement[, fromIndex]);
Parameter | Optional | Meaning |
---|---|---|
searchElement | Required | The element to search for. |
fromIndex | Optional | The position to begin searching for searchElement ; defaults to 0. |
var uint8 = new Uint32Array([1,2,3]); let a = uint8.includes(2); // true console.log(a);/*from ww w . java 2 s .co m*/ a = uint8.includes(4); // false console.log(a); a = uint8.includes(3, 3); // false console.log(a);
NaN handling
let a = new Uint32Array([NaN]).includes(NaN); // false, since the NaN passed to the constructor gets converted to 0 console.log(a);//from w w w . ja v a 2s . c om a = new Uint32Array([NaN]).includes(NaN); // true; console.log(a); a = new Uint32Array([NaN]).includes(NaN); // true; console.log(a);