Skip to content

Instantly share code, notes, and snippets.

@jung-kim
Last active February 4, 2016 20:18
Show Gist options
  • Save jung-kim/9f687dc9a2f385d769c1 to your computer and use it in GitHub Desktop.
Save jung-kim/9f687dc9a2f385d769c1 to your computer and use it in GitHub Desktop.
map vs obj
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