The Javascript BigUint64Array 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()
.
BigUint64Array.lastIndexOf(searchElement[, fromIndex = BigUint64Array.length])
Parameter | Optional | Meaning |
---|---|---|
searchElement | Required | Element to locate in the typed array. |
fromIndex | Optional | The 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 BigUint64Array([2n, 5n, 9n, 2n]); let a = uint8.lastIndexOf(2); console.log(a);//w w w. j a v a 2s.c o m 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);