Open In App

JavaScript Map constructor Property

Last Updated : 02 Jun, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

The map constructor property in JavaScript is used to return the map constructor function for the object. The function which is returned by this property is just the reference to this function, not a map containing the function’s name. The JavaScript map constructor, string constructor, and boolean constructor return function Map() { [native code] }, function String() { [native code] }, and function Boolean() { [native code] } respectively. 

Syntax:

map.constructor

Return Value: Map() { [native code] }

Example 1: This example shows the basic use of the Map constructor property in JavaScript.

Javascript




function func() {
    let map1 = new Map([
        [1, 2],
        [2, 3],
        [4, 5]
    ]);
    let value = map1.constructor;
    console.log(value);
}
func();


Output:

Æ’ Map() { [native code] }

Example 2: This example uses the Map constructor Property of Javascript.

Javascript




function myGeeks() {
    let map1 = new Map([
        [1, 2],
        [2, 3],
        [4, 5]
    ]);
 
    console.log(map1.constructor);
}
myGeeks()


Output

[Function: Map]

Supported Browsers:

  • Chrome
  • Edge
  • Firefox
  • Safari
  • Opera
  • Internet Explorer

We have a complete list of JavaScript Map methods, to check those please go through the JavaScript Map Reference article


Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads