Created
November 21, 2019 19:40
-
-
Save danfinlay/cbda4c2b03fb4de73627bd319b80d089 to your computer and use it in GitHub Desktop.
Proof that JavaScript maps index functions by identity, not source string.
This file contains 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 funcString = '() => "foo"'; | |
const funcA = new Function(funcString); | |
const funcB = new Function(funcString); | |
const map = new Map(); | |
map.set(funcA, 'a'); | |
map.set(funcB, 'b'); | |
const aVal = map.get(funcA); | |
console.log(aVal === 'a'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment