VOOZH about

URL: https://www.geeksforgeeks.org/javascript/lodash-_-sortedlastindexof-method/

⇱ Lodash _.sortedLastIndexOf() Method - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Lodash _.sortedLastIndexOf() Method

Last Updated : 2 Sep, 2024

The _.sortedLastIndexOf method is used to return the highest index of the array where an element can be inserted and maintain its sorted order. Also, this method is like _.lastIndexOf except that it performs a binary search on a sorted array.
Syntax:

_.sortedLastIndexOf(array, value)

Parameters: This method accepts two parameters as mentioned above and described below:

  • array: This parameter holds the array to inspect.
  • value: This parameter holds the value to search for.

Return Value: It returns the index of the matched value, else -1.

Example 1: Here, const _ = require(‘lodash’) is used to import the lodash library into the file.

Output:

4

Example 2:

Output:

7
Comment