主题
sortedLastIndex
js
_.sortedLastIndex(array, value)此方法与 _.sortedIndex 类似,不同之处在于它返回 value 应插入到 array 中的最高索引,以保持其排序顺序。
¥This method is like _.sortedIndex except that it returns the highest index at which value should be inserted into array in order to maintain its sort order.
新增于
¥Since
3.0.0
参数
¥Arguments
array(数组):要检查的排序数组。¥
array(Array): The sorted array to inspect.value(*):要评估的值。¥
value()*: The value to evaluate.
返回
¥Returns
(数值):返回应将 value 插入 array 的索引。
¥(number): Returns the index at which value should be inserted into array.
示例
¥Example
js
_.sortedLastIndex([4, 5, 5, 5, 6], 5);
// => 4