Handling Exceptions with try…catch in Javascript


Catch exceptions thrown in synchronous code.

Source Code

try {
  JSON.parse('not a JSON string');
} catch (error) {
  console.error('Failed to parse JSON', error);
}
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments