JSFiddle - React, Tailwind, and code Playground
JavaScript
function HashTable() {
this.hashes = {},
this.id = 0;
}
HashTable.prototype = {
constructor: HashTable,
put: function( obj, value ) {
obj.id = this.id;
this.hashes[ this.id ] = value;
this.id++;
},
get: function( obj ) {
return this.hashes[ obj.id ];
}
};
var myHash = new HashTable(),
object1 = {},
object2 = {};
myHash.put(object1, "value1");
myHash.put(object2, "value2");
alert(myHash.get(object1));
alert(myHash.get(object2));