Last active
June 19, 2017 05:16
-
-
Save battmanz/9ffbac3c18c6cf33d97a4ad511129e94 to your computer and use it in GitHub Desktop.
Functions that can be used in place of Map 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 map = new Map([ | |
| [1, 'one'], | |
| [2, 'two'], | |
| [3, 'three'] | |
| ]); | |
| // Instead of: map.set(4, 'four'); | |
| const map2 = new Map([...map, [4, 'four']]); | |
| // Instead of: map.delete(1); | |
| const map3 = new Map([...map].filter(([key]) => key !== 1)); | |
| // Instead of: map.clear(); | |
| const map4 = new Map(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment