Javascript BigInt64Array indexOf()

Introduction

The Javascript BigInt64Array indexOf() method returns the first index for a given element, or -1 if it is not present.

This method works the same as Array.prototype.indexOf().

BigInt64Array.indexOf(searchElement[, fromIndex = 0])
Parameter Optional Meaning
searchElementRequiredElement to find in the typed array.
fromIndex Optional The index to start the search at.

If the fromIndex is greater than or equal to the typed array's length, -1 is returned.

If the fromIndex is a negative number, it is array.length+ fromIndex.

indexOf() uses strict equality (=== operator).

var uint8 = new BigInt64Array([2n, 5n, 9n]);
let a = uint8.indexOf(2);     
console.log(a);//from   ww w.j av a2 s.c o  m
a = uint8.indexOf(7);     
console.log(a);
a = uint8.indexOf(9, 2);  
console.log(a);
a = uint8.indexOf(2, -1); 
console.log(a);
a = uint8.indexOf(2, -3); 
console.log(a);



PreviousNext

Related