_.sortedLastIndexBy(获取索引值)
语法:
_.sortedLastIndexBy(array, value, [iteratee=_.identity])源代码链接:source
npm包链接:npm package
描述:
这个方法类似_.sortedLastIndex,除了它接受一个iteratee(迭代函数),调用每一个数组(array)元素,返回结果和value值比较来计算排序。iteratee 会传入一个参数:(value)。
开始版本:4.0.0
参数:
array (Array): 要检查的排序数组。value (*): 要评估的值。[iteratee=_.identity] (Array|Function|Object|string): 迭代函数,调用每个元素。
返回值:
(number): 返回 value值 应该在数组array中插入的索引位置 index。
例子:
var objects = [{ 'x': 4 }, { 'x': 5 }];
_.sortedLastIndexBy(objects, { 'x': 4 }, function(o) { return o.x; });
// => 1
// The `_.property` iteratee shorthand.
_.sortedLastIndexBy(objects, { 'x': 4 }, 'x');
// => 1Last updated
Was this helpful?