Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

Revision 771693 of Map.prototype

  • Revision slug: Web/JavaScript/Reference/Global_Objects/Map/prototype
  • Revision title: Map.prototype
  • Revision id: 771693
  • Created:
  • Creator: jpmedley
  • Is current revision? No
  • Comment

Revision Content

{{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 that Map.prototype.has(value) would have previously returned. Map.prototype.has(key) will return false afterwards.
{{jsxref("Map.prototype.entries()")}}
Returns returns a new Iterator object that contains an array of [key, value] for each element in the Map 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, or undefined 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 the Map object or not.
{{jsxref("Map.prototype.keys()")}}
Returns a new Iterator object that contains the keys for each element in the Map object in insertion order.
{{jsxref("Map.set", "Map.prototype.set(key, value)")}}
Sets the value for the key in the Map object. Returns the Map object.
{{jsxref("Map.prototype.values()")}}
Returns a new Iterator object that contains the values for each element in the Map 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 the Map 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")}}

Revision Source

<div>{{JSRef("Global_Objects", "Map")}} {{harmony}}</div>

<h2 id="Summary" name="Summary">Summary</h2>

<p>The <code><strong>Map</strong></code><strong><code>.prototype</code></strong> property represents the prototype for the {{jsxref("Global_Objects/Map", "Map")}} constructor.</p>

<div>{{js_property_attributes(0,0,0)}}</div>

<h2 id="Description" name="Description">Description</h2>

<p>{{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 <code>Map</code> instances.</p>

<h2 id="Properties">Properties</h2>

<dl>
 <dt><code>Map.prototype.constructor</code></dt>
 <dd>Returns the function that created an instance's prototype. This is the {{jsxref("Global_Objects/Map", "Map")}} function by default.</dd>
 <dt>{{jsxref("Map.prototype.size")}}</dt>
 <dd>Returns the number of key/value pairs in the <code>Map</code> object.</dd>
</dl>

<h2 id="Methods">Methods</h2>

<dl>
 <dt>{{jsxref("Map.prototype.clear()")}}</dt>
 <dd>Removes all key/value pairs from the <code>Map</code> object.</dd>
 <dt>{{jsxref("Map.delete", "Map.prototype.delete(key)")}}</dt>
 <dd>Removes any value associated to the <code>key</code> and returns the value that <code>Map.prototype.has(value)</code> would have previously returned. <code>Map.prototype.has(key)</code> will return <code>false</code> afterwards.</dd>
 <dt>{{jsxref("Map.prototype.entries()")}}</dt>
 <dd>Returns returns a new <code>Iterator</code> object that contains<strong> an array of <code>[key, value]</code></strong> for each element in the <code>Map</code> object in insertion order.</dd>
 <dt>{{jsxref("Map.forEach", "Map.prototype.forEach(callbackFn[, thisArg])")}}</dt>
 <dd>Calls callbackFn once for each key-value pair present in the <code>Map</code> object, in insertion order. If a thisArg parameter is provided to forEach, it will be used as the this value for each callback.</dd>
 <dt>{{jsxref("Map.get", "Map.prototype.get(key)")}}</dt>
 <dd>Returns the value associated to the <code>key</code>, or <code>undefined</code> if there is none.</dd>
 <dt>{{jsxref("Map.has", "Map.prototype.has(key)")}}</dt>
 <dd>Returns a boolean asserting whether a value has been associated to the <code>key</code> in the <code>Map</code> object or not.</dd>
 <dt>{{jsxref("Map.prototype.keys()")}}</dt>
 <dd>Returns a new <code>Iterator</code> object that contains the <strong>keys</strong> for each element in the <code>Map</code> object in insertion order.</dd>
 <dt>{{jsxref("Map.set", "Map.prototype.set(key, value)")}}</dt>
 <dd>Sets the value for the <code>key</code> in the <code>Map</code> object. Returns the <code>Map</code> object.</dd>
 <dt>{{jsxref("Map.prototype.values()")}}</dt>
 <dd>Returns a new <code>Iterator</code> object that contains the <strong>values</strong> for each element in the <code>Map</code> object in insertion order.</dd>
 <dt>{{jsxref("Map.@@iterator", "Map.prototype[@@iterator]()")}}</dt>
 <dd>Returns a new <code>Iterator</code> object that contains<strong> an array of <code>[key, value]</code></strong> for each element in the <code>Map</code> object in insertion order.</dd>
</dl>

<h2 id="Specifications">Specifications</h2>

<table class="standard-table">
 <tbody>
  <tr>
   <th scope="col">Specification</th>
   <th scope="col">Status</th>
   <th scope="col">Comment</th>
  </tr>
  <tr>
   <td>{{SpecName('ES6', '#sec-map.prototype', 'Map.prototype')}}</td>
   <td>{{Spec2('ES6')}}</td>
   <td>Initial definition.</td>
  </tr>
 </tbody>
</table>

<h2 id="Browser_compatibility">Browser compatibility</h2>

<p>{{ CompatibilityTable() }}</p>

<div id="compat-desktop">
<table class="compat-table">
 <tbody>
  <tr>
   <th>Feature</th>
   <th>Chrome</th>
   <th>Firefox (Gecko)</th>
   <th>Internet Explorer</th>
   <th>Opera</th>
   <th>Safari</th>
  </tr>
  <tr>
   <td>Basic support</td>
   <td>38</td>
   <td>{{ CompatGeckoDesktop("13") }}</td>
   <td>11</td>
   <td>25</td>
   <td>7.1</td>
  </tr>
 </tbody>
</table>
</div>

<div id="compat-mobile">
<table class="compat-table">
 <tbody>
  <tr>
   <th>Feature</th>
   <th>Android</th>
   <th>Chrome for Android</th>
   <th>Firefox Mobile (Gecko)</th>
   <th>IE Mobile</th>
   <th>Opera Mobile</th>
   <th>Safari Mobile</th>
  </tr>
  <tr>
   <td>Basic support</td>
   <td>{{ CompatNo() }}</td>
   <td>38</td>
   <td>{{ CompatGeckoMobile("13") }}</td>
   <td>{{ CompatNo() }}</td>
   <td>{{ CompatNo() }}</td>
   <td>
    <p>iOS 8</p>
   </td>
  </tr>
 </tbody>
</table>
</div>

<h2 id="See_also">See also</h2>

<ul>
 <li>{{jsxref("Set.prototype")}}</li>
</ul>
Revert to this revision