Returns index of data in an ascended sorted array using a binary search. Returns -1 if data was not found.
indexOf([1,2,3], 3); // 2indexOf([1,2,3], 0); // -1, not found Copy
indexOf([1,2,3], 3); // 2indexOf([1,2,3], 0); // -1, not found
By default uses Javascript comparision semantics. Passing in comparer is needed when working with an array of objects.
comparer
Array of data
Item to search for
Start point
End index
Comparer (by default uses JS semantics)
Index of sought item or -1 if not found.
Returns index of data in an ascended sorted array using a binary search. Returns -1 if data was not found.
By default uses Javascript comparision semantics. Passing in
comparer
is needed when working with an array of objects.