Javatpoint Logo
Javatpoint Logo

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






Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA