As made clear in update 3 on this answer, this notation:
var hash = {};
hash[X]
does not actually hash the object X; it actually
You can use ECMAScript 6 WeakMap or Map:
WeakMaps are key/value maps in which keys are objects.
Map objects are simple key/value maps. Any value (both objects and primitive values) may be used as either a key or a value.
Be aware that neither is widely supported, but you can use ECMAScript 6 Shim (requires native ECMAScript 5 or ECMAScript 5 Shim) to support Map, but not WeakMap (see why).