Quick answer: Construct 3 Array IndexOf returning −1 on an array you know contains the value? IndexOf is linear, but mixing string and number entries breaks the comparison.

An array of level IDs returns −1 for IndexOf(“5”) even though the array has 5. Numbers and strings compare strictly.

Type Strictness

Construct 3 distinguishes “5” (string) from 5 (number). Array.IndexOf compares with strict equality. Coerce on the way in or use a matching type for the search.

Coerce Consistently

If your array stores numbers via Push (number), search with a number value. If it stores strings via Push (string), search with a string. Mixed arrays bite repeatedly — pick one.

ForEach for Custom Compare

For complex matches (case-insensitive strings, near-equal numbers), iterate with For Each Element and check yourself.

Verifying

IndexOf returns the right index when value and array element types match.

“IndexOf is strict. Coerce numbers and strings consistently on insert.”

Use a Dictionary instead of an Array when you need keyed lookup — O(1) and the engine handles the comparison.