As made clear in update 3 on this answer, this notation:
var hash = {}; hash[X]
does not actually hash the object X; it actually
X
There are some really great solutions nowadays with external libraries:
JavaScript also has its language-provided Map as well.
Map