Lodash - sortedLastIndex 方法
语法
_.sortedLastIndex(array, value)
此方法类似于 _.sortedIndex,只不过返回应该将值插入到数组中的最高索引,以维持其排序顺序。
参数
array (数组) − 要检查的已排序数组。
value (*) − 要评估的值。
输出
(数字) − 返回应该将值插入到数组中的索引。
范例
var _ = require('lodash');
var list = [1, 2, 5, 4, 5, 6];
var result = _.sortedLastIndex(list, 5);
console.log(result);
将上述程序保存在 **tester.js** 中。运行以下命令以执行此程序。
命令
\>node tester.js
输出
5
lodash_array.htm
广告