There are many way’s to implement it but ES6 make it so cool.


Let see how: 
let arr = [1, 2, 2, 3, 4];let distinctArray = new Set(arr);