Function Updated 17 Oct 2026
Array.indexOf(item, [fromIndex])
Returns the index of the first item that equals the given value.
Parameters
itemanyrequiredValue to search for.
fromIndexnumberoptionalIndex to start searching from. A negative value counts from the end of the array.
Returns
The index (zero-based), or -1 if the value is not found.
Items are compared by their JSON representation, so an object with the same content matches — unlike standard JavaScript, which compares objects by reference. lastIndexOf() works the same way, searching from the end.
Example
Mixed HTML (or any text file) with inline JavaScript between hash signs.
Index of the number 3 is 2:
Test result: #items.indexOf(3)#The template above produces this output:
Index of the number 3 is 2:
Test result: 2The data the example runs with:
{
"items" : [1, 2, 3]
}