The MDN documentation on Map
says:
If you're still not sure which one to use [object or map], ask yourself the following questions:
Are keys usually unknown until run time, do you need to look them up dynamically?
[...]
Those all are signs that you want a Map for a collection. [...] https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Map
But I can set keys for objects dynamicaly with square brackets too (ie. myObject[dynamicKey]
).
Is there another reason for using maps
when I have dynamic keys other than just for "fitting the Maps purpose" of being a collection?