skip to content
Rizkhal Lamaau

Javascript spread operator to get rid of duplicate value

/ 1 min read

Distribute the operator to eliminate duplicate values, with javascript we only need to write one line of code like this:

const arr = [1, 2, 3, 2, 3, 1];

const newArr = [...new Set(arr)];

console.log(newArr); // 123

Thanks for reading me ❤️