Ref: MDN Maps
Use maps over objects when keys are unknown until run time, and when all keys are the same type and all values are the same type.
Objects are similar to Maps in that both let you set keys to values, retrieve those values, delete keys, and detect whether something is stored at a key. Because of this (and because there were no built-in alternatives), Objects have been used as Maps historically; however, there are important differences that make using a Map preferable in certain cases:
Object are Strings and Symbols, whereas they can be
any value for a Map, including functions, objects, and any primitive.Map are ordered while keys added to object are not. Thus,
when iterating over it, a Map object returns keys in order of
insertion.Map easily with the size property, while
the number of properties in an Object must be determined manually.Map is an iterable and can thus be directly iterated, whereas
iterating over an Object requires obtaining its keys in some fashion
and iterating over them.Object has a prototype, so there are default keys in the map that
could collide with your keys if you're not careful. As of ES5 this
can be bypassed by using map = Object.create(null), but this is
seldom done.Map may perform better in scenarios involving frequent addition and
removal of key pairs.MDN