Practice: Working with Map Objects
Instance methods
Map.prototype.clear()
-
Removes all key-value pairs from the
Map
object. Map.prototype.delete()
-
Returns
true
if an element in theMap
object existed and has been removed, orfalse
if the element does not exist.map.has(key)
will returnfalse
afterwards. Map.prototype.entries()
-
Returns a new Iterator object that contains a two-member array of
[key, value]
for each element in theMap
object in insertion order. Map.prototype.forEach()
-
Calls
callbackFn
once for each key-value pair present in theMap
object, in insertion order. If athisArg
parameter is provided toforEach
, it will be used as thethis
value for each callback. Map.prototype.get()
-
Returns the value associated to the passed key, or
undefined
if there is none. Map.prototype.has()
-
Returns a boolean indicating whether a value has been associated with the passed key in the
Map
object or not. Map.prototype.keys()
-
Returns a new Iterator object that contains the keys for each element in the
Map
object in insertion order. Map.prototype.set()
-
Sets the value for the passed key in the
Map
object. Returns theMap
object. Map.prototype.values()
-
Returns a new Iterator object that contains the values for each element in the
Map
object in insertion order. Map.prototype[@@iterator]()
-
Returns a new Iterator object that contains a two-member array of
[key, value]
for each element in theMap
object in insertion order.