As made clear in update 3 on this answer, this notation:
var hash = {};
hash[X]
does not actually hash the object X
; it actually
According to ECMAScript 2015 (ES6), standard JavaScript has a Map implementation. More about which could be found here.
Basic usage:
var myMap = new Map();
var keyString = "a string",
keyObj = {},
keyFunc = function () {};
// Setting the values
myMap.set(keyString, "value associated with 'a string'");
myMap.set(keyObj, "value associated with keyObj");
myMap.set(keyFunc, "value associated with keyFunc");
myMap.size; // 3
// Getting the values
myMap.get(keyString); // "value associated with 'a string'"
myMap.get(keyObj); // "value associated with keyObj"
myMap.get(keyFunc); // "value associated with keyFunc"