Richard A. DeVenezia said:
Can someone explain why JavaScript arrays are not allowed to
have objects as indices ?
Would solve many a hashtable lookup problems....
Object property names are strings. If a reference to an object is used
as - objectRef[anotherObjectRef] - the anotherObjectRef reference would
be type converted to a string and the result would be used as the
property name. That property name would be the implementation defined
result of the Object.prototype.toString method (if not specifically
overridden) and would often be a string along the lines of "[object]" or
"Object [object]", so all object references would refer to the same
property. Providing an object with its own toString method that returned
a string unique to the object instance (eg "MyObject_inst122") might
allow object references to be used to index JavaScript objects.
Arrays may (normally would) have elements that may be referred to by
integer index.
Richard.