Wide view image of an Oops sign on Wooden block place over yellow background. With plenty of copy space.

Finally

We can add another block to try/catch. This is done with the “finally” keyword. What the finally code block does is run always. So even if there is an error, the finally block still runs. It runs regardless if there is an error or not. Here is the syntax…

try {
    let animal = newAnimal;
} catch(error){
    console.log(‘error: ‘, error);
} finally{
    console.log(‘this will always run’);
} 

Happy Coding!

Clay Hess

Share this post

Share on facebook
Share on twitter
Share on linkedin
Share on pinterest
Share on print
Share on email
Excuse Our Mess! We are currently remodeling!

We are currently in the process of redesigning our site. We appreciate your patience as some areas of our site show chipping and paint peeling. We hope to have it sparkling soon!

Skip to content