Skip to content

Remove duplicates from an array using Lodash

To remove duplicates from a simple array, we can use sortedUniq() method provided by Lodash.

// import lodash
import _ from "lodash";

var arr = ["one", "two", "one", "three", "one", "two", "one"];

console.log(_.sortedUniq(arr));
// => ["one", "two", "three"]

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.