主题
sortedIndexOf
js
_.sortedIndexOf(array, value)此方法与 _.indexOf 类似,不同之处在于它对已排序的 array 执行二分搜索。
¥This method is like _.indexOf except that it performs a binary search on a sorted array.
新增于
¥Since
4.0.0
参数
¥Arguments
array(数组):要检查的数组。¥
array(Array): The array to inspect.value(*):要搜索的值。¥
value()*: The value to search for.
返回
¥Returns
(数值):返回匹配值的索引,否则为 -1。
¥(number): Returns the index of the matched value, else -1.
示例
¥Example
js
_.sortedIndexOf([4, 5, 5, 5, 6], 5);
// => 1