Is there a hashmap library for JavaScript?

后端 未结 8 1750
抹茶落季
抹茶落季 2021-02-14 10:35

In JavaScript, all Objects act a bit like hashmaps. However, the keys to these hashmaps must be strings. If they\'re not, they\'re converted with toString(). Tha

相关标签:
8条回答
  • 2021-02-14 11:07

    the answer is to use two arrays, one for keys, one for values.

    var i = keys.indexOf(key)
    if (i == -1)
      {keys.push(key); values.push(value)}
    else
      {values[i] = value; }
    
    0 讨论(0)
  • 2021-02-14 11:14

    I would recommend you the jshashtable project from Tim Down.

    0 讨论(0)
提交回复
热议问题