This method is like uniq except that it only works for sorted arrays. If the input array is known to be sorted sortedUniq is faster than uniq.
uniq
sortedUniq
5.12.0
sortedUniq([1, 1, 2])// => [1, 2] Copy
sortedUniq([1, 1, 2])// => [1, 2]
The array to inspect.
Returns the new duplicate free array.
This method is like
uniq
except that it only works for sorted arrays. If the input array is known to be sortedsortedUniq
is faster thanuniq
.Since
5.12.0
Example