Search

Get index of element in an array JavaScript

> indexOf index_of method

Description
Get the index of the array position where the element is allocated.


var array = [2, 9, 9];
array.indexOf(2);     // 0
array.indexOf(9);     // 1
array.indexOf(9, 2);  // 2
arr.indexOf( searchElement, fromIndex )

SEE ALSO