JavaScript Symbol.prototype Property

The Symbol.prototype in JavaScript serves the purpose of generating the prototype for the Symbol constructor.

Note: Symbol.prototype is the parent of all symbol objects and parent of Symbol.prototype is obect.prototype.

Syntax

Example

Symbol.prototype

Parameters

No parameters

Return value

The prototype for the symbol constructor.

Browser Support

Chrome 32
Safari 8
Firefox 29
Opera 19

Example 1

Example

<script>

//JavaScript to illustrate  Symbol.prototype() 

var a = Symbol('Java');

Symbol.prototype.toString = function() 

{

  return ('Example');

}

document.write(a.toString());

//expected output: Example

</script>

Output:

Output

Example

Example 2

Example

<script>

//JavaScript to illustrate  Symbol.prototype() 

var a = Symbol('Java');

Symbol.prototype.toString = function() 

{

  return ('10');

}

document.write(a.toString());

//expected output: 10

</script>

Output:

Input Required

This code uses input(). Please provide values below: