JSFiddle - React, Tailwind, and code Playground
JavaScript
function HashTable() {
this.hashes = {};
}
HashTable.prototype = {
constructor: HashTable,
put: function( key, value ) {
this.hashes[ JSON.stringify( key ) ] = value;
},
get: function( key ) {
return this.hashes[ JSON.stringify( key ) ];
}
};
var myHash = new HashTable(),
object1 = { '1': 'hello', '2': 'world' },
object2 = { '1': 'world', '2': 'hello' };
myHash.put(object1, "value1");
myHash.put(object2, "value2");
alert(myHash.get(object1));
alert(myHash.get(object2));