indexOf()
Table of Contents
Overview
The indexOf() function takes listVariable and searchElement as arguments. It returns the first occurrence index of searchElement in listVariable.
If searchElement is not found in listVariable, it returns -1.
Note: Index starts from 0.
Return Type
- Number
Syntax
<variable> = <listVariable> .indexOf(<searchElement>);
Parameter | Description | Data type |
---|---|---|
<variable> | Variable which will contain the returned index number. | NUMBER |
<listVariable> | The list variable from which the index number of the element will be returned. | LIST |
<searchElement> | The element whose first occurrence will be checked in the list. | AS APPLICABLE |
Examples
listVar = {"Creator", "CRM", "Projects"};
firstIndex = listVar.indexOf("Creator"); //returns 0
firstIndex = listVar.indexOf("Creator"); //returns 0