Map
The Map
object holds key-value pairs and remembers the original insertion order of the keys. Any value (both objects and primitive values) may be used as either a key or a value.
Map | Object | |
Accidental Keys | A | An Note: As of ES5, this can be bypassed by using |
Key Types | A | |
Key Order | The keys in | Although the keys of an ordinary The order was first defined for own properties only in ECMAScript 2015; ECMAScript 2020 defines order for inherited properties as well. See the OrdinaryOwnPropertyKeys and EnumerateObjectProperties abstract specification operations. But note that no single mechanism iterates all of an object's properties; the various mechanisms each include different subsets of properties. ( |
Size | The number of items in a | The number of items in an |
Iteration | A |
Note:
|
Performance | Performs better in scenarios involving frequent additions and removals of key-value pairs. | Not optimized for frequent additions and removals of key-value pairs. |
Examples:
Last updated