I want to create a hash with DOM elements as keys. This is illustrated by the following code:
var hash = {};
var set = function(element, value) { hash[element] = value; };
var get = function(element) { return hash[element]; };
set(document.getElementById('foo'), 'bar');
get(document.getElementById('foo')); // returns 'bar'
How can I ensure that hash maps to a unique value for each Element
?
Note that I can't use the raw ID string as key, because any arbitrary Element
may be passed in, including those without a id.