Open In App

JavaScript Map constructor Property

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.






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.




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

Output
[Function: Map]

Supported Browsers:

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

Article Tags :