Javascript: Accessing properties of keys of a Hashtable
<p>I wanted to use a hashtable as set of some objects for a graphic libray, so that I can quickly remove these objects by saying something like <code>set.remove(v2)</code>.</p>

<p>But it appears I cannot use these objects while I try to iterate the set, since the keys don't have the right properties, even though a <code>==</code> shows that they are the same objects!</p>

<p>What can I do to iterate the set and use the properties or functions which are part of the keys?</p>

<p>Test case shown below, with rather unexpected results (for me)!</p>

<pre><code>v1={'a':2,'b':3};
set={};
set[v1]=true;

// Access the object within set
var v2; for(var k in set) v2=k;

// At this moment, v2 and v1 should be the same object, but...

console.log(v2==v1);    // returns true
console.log(JSON.stringify(v1)); // returns {"a":2,"b":3}
console.log(JSON.stringify(v2)); // returns "[object Object]"   !!!
console.log(v1.a);  // returns 2
console.log(v2.a);  // causes error 'reference to undefined property v2.a' !!!
</code></pre>
