The Javascript Int32Array 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()
.
Int32Array.indexOf(searchElement[, fromIndex = 0])
Parameter | Optional | Meaning |
---|---|---|
searchElement | Required | Element 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 Int32Array([2, 5, 9]); let a = uint8.indexOf(2); console.log(a);//from w ww .j av a 2 s . co 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);