JS Built-ins
ErrortoStringbeginner

Error.toString() β€” 'Error: oops'

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

toString() returns a string combining the error's name and message.

Error.prototype.toString()

error.toString() returns "ErrorName: message".

Challenge: Verify new Error('oops').toString().

πŸ’‘ Hints (1)
  • β€’ toString() combines the name and message with ": ".