Files
30-seconds-of-code/snippets/distinctValuesOfArray.md
2017-12-17 17:55:51 +02:00

11 lines
257 B
Markdown

### distinctValuesOfArray
Returns all the distinct values of an array.
Use ES6 `Set` and the `...rest` operator to discard all duplicated values.
```js
const distinctValuesOfArray = arr => [...new Set(arr)];
// unique([1,2,2,3,4,4,5]) -> [1,2,3,4,5]
```