JavaScript Symbol valueOf() Method Last Updated : 22 May, 2023 Comments Improve Suggest changes Like Article Like Report 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 method returns the primitive value of the given symbol object. JavaScript code to show the working of this method. Example-1: javascript // Some symbol objects are created const symbol1 = Symbol('Geeks'); const symbol2 = Symbol("Geeks"); const symbol3 = Symbol(123); const symbol4 = Symbol(); // Calling the symbol.valueOf() method let result1 = symbol1.valueOf(); let result2 = symbol2.valueOf(); let result3 = symbol3.valueOf(); let result4 = symbol4.valueOf(); // Getting the primitive value console.log(result1); console.log(result2); console.log(result3); console.log(result4); Output: > Symbol(Geeks) > Symbol(Geeks) > Symbol(123) > Symbol() Example-2: javascript // Some symbol objects are created const symbol1 = Symbol('Geeks' + 'for' + 'Geeks'); const symbol2 = Symbol(2 + 3); const symbol3 = Symbol(10 / 5); const symbol4 = Symbol(1, 2, 3); // Calling the symbol.valueOf() method let result1 = symbol1.valueOf(); let result2 = symbol2.valueOf(); let result3 = symbol3.valueOf(); let result4 = symbol4.valueOf(); // Getting the primitive value console.log(result1); console.log(result2); console.log(result3); console.log(result4); Output: > Symbol(GeeksforGeeks) > Symbol(5) > Symbol(2) > Symbol(1) In the above code, it can be seen that the parameter of symbol object should be a single parameter otherwise it considers the first element as the parameter and remaining are discarded. If the parameter is an arithmetic operation then it considers them as the result of the operation as the parameter. Supported Browser: Chrome 38 and aboveEdge 12 and aboveFirefox 36 and aboveOpera 25 and aboveSafari 9 and above Reference: https://devdocs.io/javascript/global_objects/symbol/valueof Comment More infoAdvertise with us Next Article JavaScript Symbol valueOf() Method K Kanchan_Ray Follow Improve Article Tags : JavaScript Web Technologies JavaScript-Symbol JavaScript-Methods Similar Reads 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 JavaScript Symbol constructor Property 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 1 min read JavaScript Symbol asyncIterator Property JavaScript Symbol asyncIterator property is used to set an object as an async iterable. Iterable properties of this object can be iterated over using a for await...of loop. An async iterable object is any object that returns a function that produces an AsyncIterator for its Symbol.asyncIterator prop 2 min read JavaScript Symbol description Property JavaScript symbol description is an inbuilt property in JavaScript that is used to return the optional description of the specified symbol objects. Syntax: Here "A" is the specified symbol object which might be Symbol('anyValues'), Symbol.iterator, Symbol.for('anyValues') etc. A.description;Paramete 1 min read JavaScript Symbol hasInstance Property JavaScript Symbol hasInstance is used to determine if a given constructor object recognizes the object as its instance. Syntax: [Symbol.hasInstance](Object) Parameters: It accepts a parameter "object". Return value: This returns true if the value is in the chain of the object otherwise false.JavaScr 1 min read JavaScript Symbol isConcatSpreadable Property JavaScript Symbol.isConcatSpreadable is a well-known symbol used to configure if a given object should be flattened to its array elements while using the Array.prototype.concat() method. Syntax: Array[Symbol.isConcatSpreadable]Here Array is the array object which is to be flattened to its array elem 2 min read JavaScript Symbol iterator Property It is an object of Iterables which is also a kind of generalized arrays. Iterables that make any object easier to use in a for..of the loop. We know that arrays are iterative in nature but other than that, there are also several objects which are used for the iterative purpose. Suppose if any object 2 min read JavaScript Symbol match Property JavaScript Symbol match property is used to identify the matching of a regular expression against a string and this function is called using String match() method. Syntax: regexp[Symbol.match] = false; Parameters: It does not accept any parameters. Return value: It will return the Boolean value for 1 min read JavaScript Symbol matchAll Property JavaScript Symbol matchAll property used to return the regular expression that matches against a string. JavaScript String matchAll() method calls this property. Syntax: regExp[Symbol.matchAll](str); Parameter: It takes a string used to find matches of the regular expression against the string. Retu 2 min read JavaScript Symbol replace Property JavaScript Symbol replace the property is used to determine the method that replaces the matched substring of a string. This function is called by the String replace() method. Syntax: [Symbol.replace](string) Parameters: It accepts single parameter "String". Return value: It will return a new string 2 min read Like