Open In App

JavaScript Symbol constructor Property

Last Updated : 29 May, 2023
Comments
Improve
Suggest changes
Like Article
Like
Report

JavaScript Symbol constructor property is used to return the Symbol 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:

symbol.constructor

Below examples will illustrate the Symbol Constructor Property:

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

JavaScript
function fun(){
    let x = Symbol();
    console.log(x.constructor)
}
fun();

Output:

ƒ Symbol() { [native code] }

Example 2: 

JavaScript
function myGeeks() {
    let str = Symbol();

    console.log(str.constructor);
}
myGeeks()

Output
[Function: Symbol]

Supported Browsers:

  • Chrome
  • Edge
  • Firefox
  • Opera
  • Safari

We have a complete list of JavaScript Symbol, to check Please go through the JavaScript Symbol Reference article


Next Article
Article Tags :

Similar Reads

  翻译: