Map
Last updated
Last updated
In general, dont use unless you need nonstring keys or insertion order
Map()
is funcitonally equivalent to objects but:
Provides get
, set
, has
, delete
, and size
methods.
Accepts any type for the keys instead of just strings.
Provides an iterator for easy for-of
usage and maintains the order of results.
Doesn't have edge cases with prototypes and other properties showing up during iteration or copying.
Slower than just objects, b/c
Maps can be bigger than objects (16.7M vs 11.1M in Chrome)
Can be more cumbersome than objects
Harder to debug in console