Update snippet descriptions
This commit is contained in:
@ -3,9 +3,10 @@ title: uniqueElements
|
||||
tags: array,beginner
|
||||
---
|
||||
|
||||
Returns all unique values in an array.
|
||||
Finds all unique values in an array.
|
||||
|
||||
- Create a `Set` from the given array to discard duplicated values, then use the spread operator (`...`) to convert it back to an array.
|
||||
- Create a `new Set()` from the given array to discard duplicated values.
|
||||
- Use the spread operator (`...`) to convert it back to an array.
|
||||
|
||||
```js
|
||||
const uniqueElements = arr => [...new Set(arr)];
|
||||
|
||||
Reference in New Issue
Block a user