In this post, you will learn how to remove duplicates from a javascript array. You can remove duplicate values from an array in several ways but here in this post we gonna look at two simple approaches.
Remove duplicates from an array using a Set
Using the Set constructor and the spread syntax:
const names = ["Evan","Mike","Matt","Nancy","Adam","Jenny","Nancy","Carl"];
let uniqueNames = [...new Set(names)];
console.log(uniqueNames );
Remove duplicates from an array using Lodash
const names = ["Evan","Mike","Matt","Nancy","Adam","Jenny","Nancy","Carl"];
let uniqueNames = _.uniq(names);
console.log(uniqueNames );