Last active
February 4, 2016 20:18
-
-
Save jung-kim/9f687dc9a2f385d769c1 to your computer and use it in GitHub Desktop.
map vs obj
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 a = {a: 1} | |
var b = {b: 2} | |
var map = new Map(); | |
var obj = {}; | |
obj[a] = "***"; | |
obj[b] = "###"; | |
map.set(a, "***"); | |
map.set(b, "###"); | |
console.log('// obj[a] === obj[b]'); | |
console.log('obj[a]: ', obj[a]); | |
console.log('obj[b]: ', obj[b]); | |
console.log(); | |
console.log('// map.get(a) !== map.get(b)'); | |
console.log('map.get(a): ', map.get(a)); | |
console.log('map.get(b): ', map.get(b)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment