Policies & Guidelines

INDEX_OF

Get index of item in array

Description

Returns the first index at which a given item can be found in the source array.

If the given item cannot be found, null is returned instead.

Function signature

INDEX_OF(values: Array, item: ) => Number

Parameter

Description

Values

Array

Item

Item to locate in the array

Examples

numbers = [1,2,3]
complexArray = [1,0,2,"test",null,null,[1,2,3],{"a":10},[],{},false,true]
emptyArray = []
arraySmall = [1,2,3]
emptyObject = {}
object = {"a":10}

Formula

Return value

INDEX_OF(numbers, 1)

0

INDEX_OF(numbers, 2)

1

INDEX_OF(numbers, null)

null

INDEX_OF(complexArray, 0)

1

INDEX_OF(complexArray, "test")

3

INDEX_OF(complexArray, true)

11

INDEX_OF(complexArray, emptyArray)

8

INDEX_OF(complexArray, arraySmall)

6

INDEX_OF(complexArray, emptyObject)

9

INDEX_OF(complexArray, object)

7