Symbol.toStringTag JavaScript

The JavaScript Symbol.toStringTag property creates the default string description of an object. The Object.prototype.toString() method internally use it. Syntax: Symbol.toStringTag Example 1: <!DOCTYPE html> <html> <body> <script> class obj {get [Symbol.toStringTag]() { return ‘HELLO’; } } document.write(Object.prototype.toString.call(new obj())); </script> </body> </html> Example 2: <!DOCTYPE html> <html> <body> <script> class TestDisplay { get [Symbol.toStringTag]() { return … Read more