Using try…catch for Error Handling in Javascript


try…catch is used to catch errors in a block of code.

Source Code

try {
  throw new Error('Something went wrong');
} catch (error) {
  console.log(error.message);
}
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments