3 ms·
>The nicest part of it is the built-in hash table type and the related syntactic sugar that everyone for whatever reasons insists on calling "object". People c
by anon1385 12y ago
>The nicest part of it is the built-in hash table type and the related syntactic sugar that everyone for whatever reasons insists on calling "object".
People call it an object because that is what it is. If your code is using Javascript objects as general purpose hash tables with the normal syntactic sugar then your code is broken[1]. The correct way to use an object as a hash table involves a bunch of ugly extra syntax that makes it more verbose than hash tables in any other language I'm aware of.
[1] http://www.devthought.com/2012/01/18/an-object-is-not-a-hash/ http://www.devthought.com/2012/01/18/an-object-is-not-a-hash...
- deleted 12y ago[deleted]
- nateroling 12y agoObject.create(null) creates an empty object with no prototype that you can safely use as a hash, as mentioned in the article you linked.