Files
30-seconds-of-code/snippets/distinctValuesOfArray.md
Angelos Chalaris 5c2eeb3bcc Updated examples
2017-12-27 16:06:16 +02:00

14 lines
280 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)];
```
```js
distinctValuesOfArray([1,2,2,3,4,4,5]) // [1,2,3,4,5]
```