Home » JavaScript TypedArray lastIndexOf() Method

JavaScript TypedArray lastIndexOf() Method

by Online Tutorials Library

JavaScript TypedArray lastIndexOf() Method

The JavaScript lastIndex()of method returns the last position of a value, or it returns -1 if the value is not found.

NOTE: The string is searched from the end to the beginning, but returns the index starting from the beginning, at position 0.

The lastIndexof() method is case sensitive.

Syntax:

Parameters:

Value: The first parameter is value that is going to be searched in the array.

Start: It refers the position where to start the search. If the value is not given in the argument, the default value is the length of the array.

Return value:

Representing the index of the element where the value is found for the last time, or -1 if the value cannot be found.

Browser Support:

Chrome Yes
Safari Yes
Firefox Yes
Opera

Example

JavaScript lastIndexOf() Method

Test it Now

Output:

4  

Example 2

JavaScript lastIndexOf() Method

Test it Now

Output:

-1  

You may also like