30 seconds of code

  Back to Home

uniqueElements

arraybeginner

Returns all unique values of an array.

Use ES6 Set and the ...rest operator to discard all duplicated values.

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