Created
June 19, 2017 05:25
-
-
Save battmanz/d42d3224c99d76d780f68daaa6a87338 to your computer and use it in GitHub Desktop.
Functions that can be used in place of Set mutator methods.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const set = new Set(['A', 'B', 'C']); | |
| // Instead of: set.add('D'); | |
| const set2 = new Set([...set, 'D']); | |
| // Instead of: set.delete('B'); | |
| const set3 = new Set([...set].filter(key => key !== 'B')); | |
| // Instead of: set.clear(); | |
| const set4 = new Set(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment