$indexOfArray

The `$indexOfArray` operator searches an array for an occurrence of a specified value and returns the array index of the first occurrence. If the value is not found, returns -1.

Syntax

{ $indexOfArray: [ <array expression>, <search expression>, <start>, <end> ] }

Parameters

<array expression>stringrequired

An expression that resolves to an array.

<search expression>stringrequired

An expression that resolves to the value to search for.

<start>number

Optional integer that specifies the starting index position for the search.

<end>number

Optional integer that specifies the ending index position for the search.