indexOf :: Array

indexOf(value) -> position Returns the position of the first occurrence of the argument within the array. If the argument doesn’t exist in the array, returns -1.

Note: this uses the == equivalence operator, not the === strict equality operator. The bottom example below illustrates this.

Minor note: this uses a plain old optimized indexing loop, so there’s no risk of extensions being detected by this method.

Example

[3, 5, 6, 1, 20].indexOf(1)

// -> 3

[3, 5, 6, 1, 20].indexOf(90)

// -> -1

[0, false, 15].indexOf(false)

// -> 0 instead of 1, because 0 == false!

Prototype API 1.5.0 - prototypejs.org