Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
JavaScript Hates You
var foo = new Object();
var bar = new Object();
var map = new Object();
map[foo] = "foo"; // --> map["[Object object]"] = "foo";
map[bar] = "bar"; // --> map["[Object object]"] = "bar";
// NOTE: second mapping REPLACES first mapping!
alert(map[foo]); // --> alert(map["[Object object]"]);
// and since map["[Object object]"] = "bar",
// this will alert "bar", not "foo"!!
// SURPRISE! ;-)
// Code snippet from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment