DEV Community

Discussion on: What is hashtable in javascript and in what scenarios one must decide to use hashtable as a data structure ?

Collapse
 
renannobile profile image
Renan Lourençoni Nobile

You're probably talking about an object const hashtable = {}.

In JS, everything is an object (like in Ruby), and here you can store any key/value pair.

Objects are very useful in any occasion unless you just need a single variable or a list (array). Of course I'm not extending to classes and O.

You access object's data using the key you need const age = person.age //or person['age'] and set it's value the same way person.name = "john" //person["name"] = "john".