Javascript BigInt64Array lastIndexOf()

Introduction

The Javascript BigInt64Array lastIndexOf() method returns the last index for a given element.

It returns -1 if not found.

The typed array is searched backwards, starting at fromIndex.

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

BigInt64Array.lastIndexOf(searchElement[, fromIndex = BigInt64Array.length])
Parameter Optional Meaning
searchElement Required Element to locate in the typed array.
fromIndex OptionalThe index at which to start searching backwards.

fromIndex defaults to the typed array's length.

If the fromIndex is greater than or equal to the array.length, the whole typed array will be searched.

If negative, uses array.length+fromIndex.

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

var uint8 = new BigInt64Array([2n, 5n, 9n, 2]);
let a = uint8.lastIndexOf(2);     
console.log(a);//  w  w  w  .jav  a 2  s . c om
a = uint8.lastIndexOf(7);     
console.log(a);
a = uint8.lastIndexOf(2, 3);  
console.log(a);
a = uint8.lastIndexOf(2, 2);  
console.log(a);
a = uint8.lastIndexOf(2, -2); 
console.log(a);
a = uint8.lastIndexOf(2, -1); 
console.log(a);



PreviousNext

Related