Docly Developers
Function Updated 17 Oct 2026

Array.indexOf(item, [fromIndex])

Returns the index of the first item that equals the given value.

Parameters

itemanyrequired

Value to search for.

fromIndexnumberoptional

Index 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)#