JS Built-ins
ErrortoStringbeginner

Error.toString() β€” TypeError

πŸ“– Usage Example
new TypeError('bad').toString()  // β†’ 'TypeError: bad'

Subclasses include their own name in the toString() output.

TypeError.toString()

new TypeError('bad').toString() returns 'TypeError: bad'.

Challenge: Verify the result.

πŸ’‘ Hints (1)
  • β€’ Each Error subclass uses its own name in toString().