indexOf

Checks if the first argument string ends with a specific string (second argument string). If the string is not found, return -1.

Category

String

Function syntax

indexOf(<parameters>)

Parameters

Parameter Type
string String
specified value String

Signature and returned type

indexOf(<string>,<string>)

Returns an integer.

Example

indexOf("Hello", "l")

Returns 2.

Explanation:

In “Hello”, the first occurrence of “l” is at position 2.

On this page

Adobe Summit Banner

A virtual event April 27-28.

Expand your skills and get inspired.

Register for free
Adobe Summit Banner

A virtual event April 27-28.

Expand your skills and get inspired.

Register for free
Adobe Maker Awards Banner

Time to shine!

Apply now for the 2021 Adobe Experience Maker Awards.

Apply now
Adobe Maker Awards Banner

Time to shine!

Apply now for the 2021 Adobe Experience Maker Awards.

Apply now