Search code examples
javascriptjqueryprototypejshashtable

Prototype JS Hash Table alternative/solution for Jquery


Hi everybody I'm a prototype js developer and I'm moving for work/client reasons to jquery. I'm a big fan of Prototype Hash var h = new Hash(); class I know that in jQuery is not any hash table available at least in the core, I would like to know what it the best alternative to have a good practice/solution in a way to manage my data structure in a pretty same way as I do it with the hash table? of course using Jquery.


Solution

  • If you're only using strings as keys, you can use a plain old object (since you're no longer using Prototype, you don't have to worry much about overwriting things):

    var h = {};
    h.somekey = somevalue;
    h.someotherkey = someothervalue;
    h[dynamickey] = val;