4 ms·
When I first saw this post, it didn't include the following snippet: Object.create(null); I disagreed adamantly that a hash with pre-defined names is not
by just2n 14y ago
When I first saw this post, it didn't include the following snippet:
Object.create(null);
I disagreed adamantly that a hash with pre-defined names is not a hash. The language already provides a means to get a hash without the pre-defined names, and any clever person can hack around naming collisions regardless. He now notes these things at the end of the article, but then the entire argument doesn't imply that a hash is not a hash. He does a good job pointing out a mistake ALMOST EVERYONE makes, and I applaud that, but the title is horribly misleading, even when given the proper context.
Also, @mcot2, I didn't intend to post as a reply to you, but since I have, to answer your question, collections (Maps, Sets, and WeakMaps) are available in V8 and consequently Node already (via --harmony flags). Because the implementations of these with get/set is not tied to the object's properties, these don't have the same problem.
- comex 14y agoIsn't the whole point of Maps that their get/set methods are completely independent from object properties?