{{JSRef("Global_Objects", "Map")}} {{harmony}}
Summary
The Map
.prototype
property represents the prototype for the {{jsxref("Global_Objects/Map", "Map")}} constructor.
{{js_property_attributes(0,0,0)}}
Description
{{jsxref("Global_Objects/Map", "Map")}} instances inherit from {{jsxref("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 {{jsxref("Global_Objects/Map", "Map")}} function by default.
- {{jsxref("Map.prototype.size")}}
- Returns the number of key/value pairs in the
Map
object.
Methods
- {{jsxref("Map.prototype.clear()")}}
- Removes all key/value pairs from the
Map
object. - {{jsxref("Map.delete", "Map.prototype.delete(key)")}}
- Removes any value associated to the
key
and returns the value thatMap.prototype.has(value)
would have previously returned.Map.prototype.has(key)
will returnfalse
afterwards. - {{jsxref("Map.prototype.entries()")}}
- Returns a new
Iterator
object that contains an array of[key, value]
for each element in theMap
object in insertion order. - {{jsxref("Map.forEach", "Map.prototype.forEach(callbackFn[, thisArg])")}}
- Calls callbackFn once for each key-value pair present in the
Map
object, in insertion order. If a thisArg parameter is provided to forEach, it will be used as the this value for each callback. - {{jsxref("Map.get", "Map.prototype.get(key)")}}
- Returns the value associated to the
key
, orundefined
if there is none. - {{jsxref("Map.has", "Map.prototype.has(key)")}}
- Returns a boolean asserting whether a value has been associated to the
key
in theMap
object or not. - {{jsxref("Map.prototype.keys()")}}
- Returns a new
Iterator
object that contains the keys for each element in theMap
object in insertion order. - {{jsxref("Map.set", "Map.prototype.set(key, value)")}}
- Sets the value for the
key
in theMap
object. Returns theMap
object. - {{jsxref("Map.prototype.values()")}}
- Returns a new
Iterator
object that contains the values for each element in theMap
object in insertion order. - {{jsxref("Map.@@iterator", "Map.prototype[@@iterator]()")}}
- Returns a new
Iterator
object that contains an array of[key, value]
for each element in theMap
object in insertion order.
Specifications
Specification | Status | Comment |
---|---|---|
{{SpecName('ES6', '#sec-map.prototype', 'Map.prototype')}} | {{Spec2('ES6')}} | Initial definition. |
Browser compatibility
{{ CompatibilityTable() }}
Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|
Basic support | 38 | {{ CompatGeckoDesktop("13") }} | 11 | 25 | 7.1 |
Feature | Android | Chrome for Android | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|---|
Basic support | {{ CompatNo() }} | 38 | {{ CompatGeckoMobile("13") }} | {{ CompatNo() }} | {{ CompatNo() }} |
iOS 8 |
See also
- {{jsxref("Set.prototype")}}