JS: Map.prototype

By Xah Lee. Date: . Last updated: .

New in ES2015.

Map.prototype is the value of the property key "prototype" of the function Map.

[see JS: Map Object]

console.log( Map.hasOwnProperty ( "prototype" ) ); // true

Type of Map.prototype is object.

[see JS: Data Types]

// type of Map.prototype
console.log ( typeof Map.prototype === "object" ); // true
console.log ( Object.prototype.toString.call( Map.prototype ) === "[object Map]" ) // true

Parent of Map.prototype is Object.prototype.

// parent of Map.prototype
console.log ( Object.getPrototypeOf ( Map.prototype ) === Object.prototype ); // true

[see JS: Prototype and Inheritance]

Map.prototype is the parent of all map instances.

console.log ( Object.getPrototypeOf ( new Map() ) === Map.prototype ); // true

The purpose of Map.prototype object is to provides methods and properties useful for all map instances.

Properties

  1. Map.prototype.constructor
  2. get Map.prototype.size

get, set

  1. Map.prototype.get ( key )
  2. Map.prototype.set ( key , value )
  3. Map.prototype.has ( key )
  4. Map.prototype.delete ( key )
  5. Map.prototype.clear ( )

loop

  1. Map.prototype.forEach ( f, this )
  2. Map.prototype.keys ( )
  3. Map.prototype.values ( )
  4. Map.prototype.entries ( )

misc

  1. Map.prototype [ Symbol.iterator ]( )
  2. Map.prototype [ Symbol.toStringTag ]

Map.prototype.constructor

Map.prototype.constructor → value is Map

console.log ( Map.prototype.constructor === Map ); // true
console.log ( (new Map()).constructor === Map ); // true

[see JS: Map Object]

[see JS: Property Key "constructor"]

ECMAScript 2015 §Keyed Collection#sec-map.prototype.constructor

Map.prototype.size

[see JS: Map.prototype.size]

Map.prototype.get

[see JS: Map.prototype.get]

Map.prototype.set

[see JS: Map.prototype.set]

Map.prototype.has

[see JS: Map.prototype.has]

Map.prototype.delete

[see JS: Map.prototype.delete]

Map.prototype.clear

[see JS: Map.prototype.clear]

Map.prototype.forEach

[see JS: Map.prototype.forEach]

Map.prototype.keys

[see JS: Map.prototype.keys]

Map.prototype.values

[see JS: Map.prototype.values]

Map.prototype.entries

[see JS: Map.prototype.entries]

Map.prototype [ Symbol.iterator ]

Map.prototype [ Symbol.iterator ] ( ) → same as Map.prototype.entries ( )

[see JS: Map.prototype.entries]

ECMAScript 2015 §Keyed Collection#sec-map.prototype-@@iterator

Map.prototype [ Symbol.toStringTag ]

Map.prototype [ Symbol.toStringTag ] → Value is the string "Map".

[see JS: Determine Type of Object]

console.log ( Map.prototype [ Symbol.toStringTag ] === "Map" ); // true

ECMAScript 2015 §Keyed Collection#sec-map.prototype-@@tostringtag

Reference

ECMAScript 2015 §Keyed Collection#sec-properties-of-the-map-prototype-object

Map Topic

  1. JS: the Map Object Tutorial
  2. JS: Map Object
  3. JS: Map.prototype
  4. JS: Iterate Over Map Object
  5. JS: Convert Object to/from Map
Liket it? Put $5 at patreon.

Or, Buy JavaScript in Depth

Ask me question on patreon