Javascript BigUint64Array includes()

Introduction

The Javascript BigUint64Array 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().

BigUint64Array.includes(searchElement[, fromIndex]);
Parameter Optional Meaning
searchElementRequired The element to search for.
fromIndexOptional The position to begin searching for searchElement; defaults to 0.
var uint8 = new BigUint64Array([1n,2n,3n]);
let a = uint8.includes(2);     // true
console.log(a);/* w w w  .  j a v a2 s . c  o  m*/
a = uint8.includes(4);     // false
console.log(a);
a = uint8.includes(3, 3);  // false
console.log(a);

NaN handling

let a = new BigUint64Array([NaN]).includes(NaN); // false, since the NaN passed to the constructor gets converted to 0
console.log(a);//from w ww  . j a  v a 2  s  .c  o m
a = new BigUint64Array([NaN]).includes(NaN); // true;
console.log(a);
a = new BigUint64Array([NaN]).includes(NaN); // true;
console.log(a);



PreviousNext

Related