List - indexOf

This topic describes the syntax and usage of the list - indexOf function in Zoho Creator .


The indexOf function returns the position of a givenn elemment in the list. The first element will be at index '0', the second element at "1" and so on.



The indexOf function syntax has the following arguments.

list - Required - The list from which you want to get the index of the element.

element- Required. The element to be searched for.


Return Value

Returns the position of a given element in the list


colors = {"red", "blue", "green", "yellow"};

colors.indexOf("red");  // returns the index number "0"

colors.indexOf("green");  // returns the index number "2"