Created
January 13, 2020 14:39
-
-
Save cesarkohl/e3ee0cb764757b6cc919fd213374a3b2 to your computer and use it in GitHub Desktop.
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
| var weakMap = new WeakMap (); | |
| var element1 = window; | |
| var element2 = document.querySelector ('body'); | |
| weakMap.set (element1, 'I am element1'); | |
| weakMap.set (element2, 'I am element2'); | |
| At this time, when we retrieve the values through the keys, we will get the expected result: | |
| console.log (weakMap.get (element1)); | |
| console.log (weakMap.get (element2)); | |
| // output | |
| // I am element1 | |
| // I am element2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment