JavaScript hashmap equivalent

前端 未结 17 1388
执笔经年
执笔经年 2020-11-22 13:23

As made clear in update 3 on this answer, this notation:

var hash = {};
hash[X]

does not actually hash the object X; it actually

17条回答
  •  天涯浪人
    2020-11-22 14:25

    This looks like a pretty robust solution: https://github.com/flesler/hashmap

    It will even work well for functions and objects that look identical. The only hack it uses is adding an obscure member to an object to identify it. If your program doesn't overwrite that obscure variable (it's something like hashid), you're golden.

提交回复
热议问题