Open In App

JavaScript WeakMap constructor Property

Improve
Improve
Like Article
Like
Save
Share
Report

JavaScript WeakMap constructor property is used to return the WeakMap constructor function for the object. The function returned by this property is just the reference, not the actual WeakMap. It is an object property of JavaScript and can be used with Strings, Numbers, etc.

Syntax:

weakset.constructor

Return Type: WeakMap() { [native code] }

Below examples will illustrate the WeakSet Constructor Property:

Example 1: In this example, we will see the basic use of WeakSet Constructor Property in JavaScript.

Javascript




function fun(){
    let x = new WeakMap();
    console.log(x.constructor)
}
fun();


Output:

Æ’ WeakMap() { [native code] }

Example 2: In this example, we will use this property to print on the browser window

Javascript




function myGeeks() {
    let looseSet = new WeakMap();
 
    console.log(looseSet.constructor);
}
myGeeks()


Output

[Function: WeakMap]

Supported Browsers:

  • Google Chrome 
  • Edge 
  • Firefox 
  • Internet
  • Opera 
  • Safari 

We have a complete list of Javascript WeakMap methods, to check those please go through Javascript WeakMap Reference article


Last Updated : 29 May, 2023
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads