Lodash – sortedLastIndex method

  • Post author:
  • Post category:Lodash
  • Post comments:0 Comments
Lodash - sortedLastIndex method

Syntax Of Lodash sortedLastIndex method

_.sortedLastIndex(array, value)

This Lodash sortedLastIndex method is like _.sortedIndex except that it returns the highest index at which value should be inserted into an array in order to maintain its sort order.

Arguments

  • array (Array) − The sorted array to inspect.
  • value (*) − The value to evaluate.

Output

  • (number) − Returns the index at which value should be inserted into array.

Example

var _ = require('lodash');
var list = [1, 2, 5, 4, 5, 6];

var result = _.sortedLastIndex(list, 5);
console.log(result);

Save the above program in tester.js. Run the following command to execute this program.

Command

\>node tester.js

Output

5

Next Topic – Click Here

Leave a Reply