What is purpose of onError event handler in JavaScript?

1 Answer(s)

The onerror event handler was the first feature to facilitate error handling for JavaScript. The error event is fired on the window object whenever an exception occurs on the page.

The onerror event handler provides three pieces of information to identify the exact nature of the error −

  • Error message − The same message that the browser would display for the given error.
  • URL − The file in which the error occurred.
  • Line number − The line number in the given URL that caused the error.
Supporter Answered on August 15, 2019.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.