JS Built-ins
ErrortoStringbeginner

Error.toString() β€” empty message gives just name

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

If the message is empty, toString() returns just the name.

Error.toString() No Message

When the message is empty, error.toString() returns just the name: 'Error'.

Challenge: Verify the result for an Error with no message.

πŸ’‘ Hints (1)
  • β€’ When there is no message, only the name is returned β€” no colon.