Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hashtable vs objects In javascript

I’m new to data structure and I’m learning it in Javascript.

My Question is: Why do we need hash tables when we 've objects in javascript? Can anybody give me a situation where hash tables will be more useful than objects?

like image 279
Zullu Avatar asked Sep 06 '25 16:09

Zullu


1 Answers

"Hashtable" is called different things in different languages. Java has Hashtable and HashMap, Ruby has Hash, Python has dict... in JavaScript, it's called Map.

Objects' keys are limited to strings; Map keys can be anything.

Objects support inheritance; a Map only contains what is specifically put into it.

like image 179
Amadan Avatar answered Sep 08 '25 12:09

Amadan