![]() |
VOOZH | about |
Lodash _.sortedIndex() method is used to return the lowest index of the array where an element can be inserted and maintain its sorted order. It uses the binary search.
_.sortedIndex(array, value);Example 1: In this example, we are getting the index number of the given value at which we can insert that value into the given array.
Output:
3Example 2: In this example, we are getting the index number of the given value at which we can insert that value into the given array.
Output:
4Note: This will not work in normal JavaScript because it requires the library lodash to be installed.