The Map.prototype property represents the prototype for the Map constructor.
Property attributes of Map.prototype |
|
|---|---|
| Writable | no |
| Enumerable | no |
| Configurable | no |
Description
Map instances inherit from Map.prototype. You can use the constructor's prototype object to add properties or methods to all Map instances.
Properties
Map.prototype.constructor- Returns the function that created an instance's prototype. This is the
Mapfunction by default. Map.prototype.size- Returns the number of key/value pairs in the
Mapobject.
Methods
Map.prototype.clear()- Removes all key/value pairs from the
Mapobject. Map.prototype.delete(key)- Removes any value associated to the
keyand returns the value thatMap.prototype.has(key)would have previously returned.Map.prototype.has(key)will returnfalseafterwards. Map.prototype.entries()- Returns a new
Iteratorobject that contains an array of[key, value]for each element in theMapobject in insertion order. Map.prototype.forEach(callbackFn[, thisArg])- Calls callbackFn once for each key-value pair present in the
Mapobject, in insertion order. If a thisArg parameter is provided to forEach, it will be used as the this value for each callback. Map.prototype.get(key)- Returns the value associated to the
key, orundefinedif there is none. Map.prototype.has(key)- Returns a boolean asserting whether a value has been associated to the
keyin theMapobject or not. Map.prototype.keys()- Returns a new
Iteratorobject that contains the keys for each element in theMapobject in insertion order. Map.prototype.set(key, value)- Sets the value for the
keyin theMapobject. Returns theMapobject. Map.prototype.values()- Returns a new
Iteratorobject that contains the values for each element in theMapobject in insertion order. Map.prototype[@@iterator]()- Returns a new
Iteratorobject that contains an array of[key, value]for each element in theMapobject in insertion order.
Specifications
| Specification | Status | Comment |
|---|---|---|
| ECMAScript 2015 (6th Edition, ECMA-262) The definition of 'Map.prototype' in that specification. |
Standard | Initial definition. |
| ECMAScript Latest Draft (ECMA-262) The definition of 'Map.prototype' in that specification. |
Draft |
Browser compatibility
| Feature | Chrome | Edge | Firefox (Gecko) | Internet Explorer | Opera | Safari |
|---|---|---|---|---|---|---|
| Basic support | 38 | (Yes) | 13 (13) | 11 | 25 | 7.1 |
| Feature | Android | Chrome for Android | Edge | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
|---|---|---|---|---|---|---|---|
| Basic support | No support | 38 | (Yes) | 13.0 (13) | No support | No support |
8 |
See also
Document Tags and Contributors
Tags:
Contributors to this page:
jameshkramer,
kdex,
jozanza,
fscholz,
fredj,
jpmedley,
BlindWanderer,
arai,
realityking,
alexeiskachykhin,
spacetime29,
kmaglione
Last updated by:
jameshkramer,