Home » JavaScript TypedArray findIndex() Method

JavaScript TypedArray findIndex() Method

by Online Tutorials Library

JavaScript TypedArray findIndex() Method

The JavaScript findIndex() method provides the index of the first element in the array that completes the given test. If the test is not satisfied, it will return -1.

  • findIndex() does not execute the function for array elements without values.
  • findIndex() does not change the original array.

Syntax:

Parameters:

Value: The value of the current element.

Index: The array index of the current element.

Arr: The array object on which the findIndex() method operated.

ThisValue: A value to be passed to the function to be used as its “this” value. If the parameter is empty, the value “undefined” will be passed as its “this” value.

Return value:

Index of the array element, otherwise it returns -1.

Browser Support:

Chrome 45.0
Edge 7.1
Firefox 25.0
Opera 32.0

Example 1

JavaScript TypedArray findIndex() Method

Test it Now

Output:

-1  

Example 2

JavaScript TypedArray findIndex() Method

Test it Now

Output:

5  

You may also like