Skip to content

Commit

Permalink
A small update to array-hacks
Browse files Browse the repository at this point in the history
  • Loading branch information
divyanshu013 authored Apr 11, 2017
1 parent 07d153c commit 1dd3636
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions _posts/en/javascript/2017-03-12-3-array-hacks.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@ I personally don’t like using `null` since JavaScript treats it as an object a
> method(...['parameter1', , 'parameter3']); // works!
```

### Unique array values
### 3. Unique array values

I always wonder why the Array constructor does not have a designated method to facilitate the use of unique array values. Spread operators are here for the rescue. Use spread operators with the `Set` constructor to generate unique array values.

```javascript
> const arr = [...new Set([1, 2, 3, 3])];
[1, 2, 3]
```
```

0 comments on commit 1dd3636

Please sign in to comment.