The JavaScript Symbol.prototype property gives a prototype for the symbol constructor. Symbol.prototype is the parent of all Symbol objects.
Syntax:
Symbol.prototype
Returns:
Prototype for the symbol constructor.
Example 1:
<!DOCTYPE html> <html> <body> <script> var alpha = Symbol('HELLO'); Symbol.prototype.toString = function() { return ('HELLO WORLD!'); } document.write(alpha.toString()); </script> </body> </html>
Example 2:
<!DOCTYPE html> <html> <body> <script> Symbol.prototype.toString = function() { return ('Symbol Test'); } var symbolTest = Symbol('w3schools'); document.write(symbolTest.toString()); </script> </body> </html>