Codementor Events

Remove Duplicates Arrays in Javascript

Published Feb 12, 2020
Remove Duplicates Arrays in Javascript

All we need do is to initialize a new set and pass in the required array we need to remove duplicates from as shown below.

const array = ["ade", "kemi", "bose", "esther", "felele", "ade"];
const uniqeSet = new Set(array);
/* this by default returns back an object of the unique value passed in the array    * above which we can spread in an array.
*/
// Set {"ade", "kemi", "bose", "esther", "felele"}
const arrayResponse = [...uniqeSet];
// ["ade", "kemi", "bose", "esther", "felele"]

Discover and read more posts from Mr. Rizwan
get started
post commentsBe the first to share your opinion
Show more replies