The _.sortedUniq method is used to return the lowest index of the array where an element can be inserted and maintain its sorted order. Also, this method is like _.uniq except that it’s designed and optimized for sorted arrays. In _.uniq only the first occurrence of each element is kept and the order of result values is determined by the order they occur in the array.
Parameters: This method accepts only one parameters as mentioned above and described below:
Return Value: This method is used to return the new duplicate free array.
Example 1: Here, const _ = require(‘lodash’) is used to import the lodash library into the file.
[ 1, 2, 3, 4 ]
['p', 'q', 'r', 't', 'u', 's', 't', 'v', 'w']
['chemistry', 'computer', 'english', 'geography', 'hindi', 'maths', 'physics']