lastIndexOf

lastIndexOf()

Overview

The lastIndexOf() function takes string and searchString as arguments. It returns the last occurrence index of searchString's first character in the string.

If the searchString is not found in the string, it returns -1.

Note:

  • Index starts from 0.
  • This function performs a case-sensitive search.

Return Type

  • Number

Syntax

<variable> = <string>.lastIndexOf(<searchString>);

(OR)

<variable> = lastIndexOf( <string>, <searchString> );
ParameterDescriptionData type
<variable>Variable which will contain the returned index number.NUMBER
<string>The string from which the index number will be returned.TEXT
<searchString>


This string's first character's last occurrence will be checked in the string.

TEXT

Examples

text="Hello world, welcome to the universe";
lastIndex = text.lastIndexOf("e");            //returns 35

Share this post : FacebookTwitter

Still can't find what you're looking for?

Write to us: support@zohodeluge.com