JavaScript Symbol.prototype Property - JavaScript Tutorial

JavaScript Symbol.prototype Property

BLUF: This tutorial on JavaScript Symbol.prototype Property provides an in-depth look at JavaScript's core features. It includes practical examples and code snippets to help you master modern JS development.
Key Discovery: JavaScript Symbol.prototype Property

Understanding JavaScript Symbol.prototype Property is crucial for building dynamic, interactive web applications. Explore the examples below to see it in action.

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:

Logic Practice
Install Logic Practice
Add to home screen for a faster app-like experience