JavaScript | symbol.description property

The symbol.description is an inbuilt property in JavaScript which is used to return the optional description of the specified symbol objects.

Syntax:

A.description;

Here “A” is the specified symbol objects which might be Symbol(‘anyValues’), Symbol.iterator, Symbol.for(‘anyValues’) etc.

Parameters: This property does not accept any parameter.

Return value: This property returns the optional description of the specified symbol objects.

JavaScript code to show the working of this function:
Example-1:

filter_none

edit
close

play_arrow

link
brightness_4
code

<script>
  
   // Calling description property over
   // some specified symbol objects
   document.write(Symbol('Geek').description +"<br>");
   document.write(Symbol.iterator.description +"<br>");
   document.write(Symbol.for('GeeksforGeeks').description +"<br>");
   document.write(Symbol('Geeks').description + 'forGeeks');
      
</script>

chevron_right


Output:

Geek
Symbol.iterator
GeeksforGeeks
GeeksforGeeks

Example-2:

filter_none

edit
close

play_arrow

link
brightness_4
code

<script>
  
   // Calling description property over
   // a specified symbol objects
   document.write(Symbol().description +"<br>");
      
</script>

chevron_right


Output:

undefined

In the above code, symbol object “Symbol()” should have some parameters otherwise it gives undefined as the output.

Supported Browsers:

  • Firefox 63
  • Google Chrome 70
  • Opera 57

Reference: https://devdocs.io/javascript/global_objects/symbol/description



My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.