Did you know that try and catch also had a finally statement?

0
1315

the code that is in finally

will be executed in any case

even if it throws an error

Example

try {
  const employee fetch('https://www.example.com/getEmployee');
} catch {
  throw new Error(error)
} finally {
  //execute code even after error arise 
}

LEAVE A REPLY

Please enter your comment!
Please enter your name here