- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
JavaScript symbol.description property
The symbol.description property in JavaScript converts a Symbol object to a primitive value. The syntax is as follows −
Symbol()[Symbol.toPrimitive](hint);
Example
<!DOCTYPE html> <html> <body> <h2>Demo Heading</h2> <p>Click to display...</p> <button onclick="display()">Result</button> <p id="test"></p> <script> function display() { const val = Symbol('john'); console.log(val[Symbol.toPrimitive]); } </script> </body> </html>
Output
Click the “Result” button −
Example
<!DOCTYPE html> <html> <body> <h2>Demo Heading</h2> <p>Click to display...</p> <button onclick="display()">Result</button> <p id="test"></p> <script> function display() { const val = Symbol(2465); var res = val[Symbol.toPrimitive](99); console.log(res) } </script> </body> </html>
Output
Click the “Result” button and get the result in Console −
- Related Articles
- symbol.description property in JavaScript
- JavaScript Math.LN10 Property
- JavaScript Symbol.hasInstance Property
- JavaScript Cursor property
- JavaScript global Property
- JavaScript Infinity Property
- JavaScript lastIndex Property
- JavaScript multiline Property
- JavaScript source Property
- JavaScript undefined Property
- JavaScript ArrayBuffer.byteLength property
- ArrayBuffer.byteLength Property in JavaScript
- DataView.byteLength property in JavaScript
- DataView.byteOffset property in JavaScript
- DataView.buffer property in JavaScript

Advertisements