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