Plus, a random object (that doesn't have a meaningful toString method) will probably result in something like "[object]" as a key, which would break when you use more objects like that as keys.
Plus, a random object (that doesn't have a meaningful toString method) will probably result in something like "[object]" as a key, which would break when you use more objects like that as keys.
One good use case for objects as keys in hashes is functions. When you use a function as a key it is reliably converted to its definition, cross-browser. Doesn't make your point any less valid though.
for(var key in obj) { if(obj.hasOwnProperty(key)) val = obj[key]; }
Or did I misunderstand the question?
Ain't JavaScript a riot? [I just found an excuse to use snowclone in an HN comment. Pats self on back]
Functions on the other hand work very well because the key is the function definition (call toString on a function). There is no reason for two functions to have the exact same definition in JavaScript.