JS ⟩ value ⟩ type ⟩ custom type name
class MyClass { // ⭐️ custom type name get [Symbol.toStringTag]() { return 'MyClass' } } typeName(new MyClass()) // "MyClass"
👉 see:typeName()
Symbol.toStringTag ⭐️ - accessed internally by Object.prototype.toString().
typeof ⟩
real-world usage
custom method that gets a more specific type ⭐️
Object.prototype.toString()
instanceof
typeName()
Last updated 2 years ago