const array = [2,5,7,5,6,4,2,4,5,8,412,477,36,8,2,34,7] const generateUniqueArray => arr => [... new Set(arr)] const result = generateUniqueArray(array) console.log(result) // [ 2, 5, 7, 6, 4, 8, 412, 477, 36, 34] // With love @kouqhar