Map
In general, dont use unless you need nonstring keys or insertion order
Overview
Map()
is funcitonally equivalent to objects but:
Provides
get
,set
,has
,delete
, andsize
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 js engines compile objects to 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
Usage
Last updated