Open In App

JavaScript WeakSet constructor Property

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

Syntax:



weakset.constructor

Return Type: WeakSet() { [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.




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

Output: 

ƒ WeakSet() { [native code] }

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




<!DOCTYPE html>
<html lang="en">
 
<head>
    <title>
        JavaScript WeakSet constructor Property
    </title>
</head>
 
<body>
    <h1 style="color:green">
        Welcome to GeeksforGeeks
    </h1>
 
    <p>
        Click the button to see WeakSet
        constructor property.
    </p>
 
    <button onclick="myGeeks()">
        click me
    </button>
 
    <p id="GFG"></p>
 
    <script>
        function myGeeks() {
            let looseSet = new WeakSet();
 
            document.getElementById("GFG").innerHTML
                = looseSet.constructor;
        }
    </script>
</body>
</html>

Output:

JavaScript WeakSet Constructor property

Supported Browsers:

We have a complete list of Javascript WeakSet Methods, to check those please go through the JavaScript WeakSet Reference article.


Article Tags :