Difference between "object" and "associative array"


What is the difference between an "object" and an "associative array" in JS? Which is a better comparison to the "hash" data structure I've seen in other languages?

Replace this line with your code.


An associative array is a mapping from unique keys to values.
That's what js objects are.
A hashmap is one way to implement an associative array.

If you need to store key-value pairs in js you may prefer to do so in a Map to avoid interference with keys that the language uses.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.