| Viewed 72 times

How to Remove Duplicates from an Array in JavaScript?


I need to Create a function that takes an array of items, removes all duplicate items and returns a new array in the same sequential order as the old array (minus duplicates).

1 Answer
Mohammad Qandeel
Answered
15

This is a very easy question, you can try this function wich will remove duplicates from an Array in JavaScript

const removeDups = arr => [...new Set(arr)];

Example

removeDups([1,1,2,3,3,2]) //  [1, 2, 3]



Related Questions