JavaScript Symbol() Method Last Updated : 21 May, 2021 Comments Improve Suggest changes Like Article Like Report Symbols are new primitive built-in object types introduced as part of ES6. Symbols return unique identifiers that can be used to add unique property keys to an object that won’t collide with keys of any other code that might add to the object. They are used as object properties that cannot be recreated. It basically helps us to enable encapsulation or information hiding. Syntax: Symbol( optional_string ) Parameters: The optional_string is an optional parameter that acts as a description of Symbol(). Return Value: This method returns a new Symbol object. Below are the examples of the Symbol() method. Example 1: JavaScript <script> let symbol1 = Symbol("Geeks") let symbol2 = Symbol("Geeks") // Each time Symbol() method // is used to create new global // Symbol console.log(symbol1 == symbol2); </script> Output: false Example 2: JavaScript <script> // Symbol returns a symbol primitive console.log(typeof Symbol("GFG")); console.log(typeof Object("GFG")); </script> Output: symbol object Comment More infoAdvertise with us Next Article JavaScript Symbol() Method F faizamu19 Follow Improve Article Tags : JavaScript Web Technologies JavaScript-Symbol JavaScript-Methods Similar Reads JavaScript Symbol for() Method The Symbol.for() is an inbuilt method in JavaScript that is used to search for the given symbol in a runtime-wide symbol registry and if found then it returns the same symbol otherwise it creates a new symbol with the same name of the given symbol into the global symbol registry and returns them. Sy 2 min read JavaScript Symbol valueOf() Method The symbol.valueOf() is an inbuilt method in JavaScript which is used to return the primitive value of a given symbol object. Syntax: Symbol().valueOf(); Here Symbol() is the symbol object whose primitive value is to be found. Parameters: This method does not take any parameter. Return value: This m 2 min read JavaScript Symbol toString() Method The symbol.toString() is an inbuilt method in JavaScript that is used to convert the specified symbol object into the string. Syntax: Symbol().toString(); Here Symbol() is the specified symbol object which is to be converted into a string. Parameters: This method does not accept any parameter. Retur 1 min read JavaScript Symbol @@toPrimitive() Method The symbol.@@toPrimitive() is an inbuilt method in JavaScript which is used to converts a given symbol object to a primitive value. Syntax: Symbol()[Symbol.toPrimitive](hint); Here Symbol() is the symbol object whose primitive value is to be found. Parameters: This method accepts an optional paramet 2 min read JavaScript Symbol() Constructor The Symbol() constructor is used to create a new symbol. The Symbol() constructor returns a value of the type of symbol with static properties. Every time we call the constructor a unique symbol is created. A Symbol constructor is a primitive data type having no object or no methods which are genera 2 min read Like