Example 1 — Demo
Core idea.
JavaScript
const o = { [Symbol.toStringTag]: "Widget" };
console.log(Object.prototype.toString.call(o));How It Works
- Tag. Custom string tag.
- toString. Uses the tag.
Symbol.toStringTag is a well-known symbol. Customizes Object.prototype.toString output for an object.
const o = { [Symbol.toStringTag]: "Widget" };
console.log(Object.prototype.toString.call(o));Core idea.
const o = { [Symbol.toStringTag]: "Widget" };
console.log(Object.prototype.toString.call(o));CODETOFUN NEWS
Get the latest IT news, programming updates, and technology trends directly on your phone.
Your daily dose of tech, straight to your feed.
6 people found this page helpful