Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
The purpose of finally (as in try{ }finally{ })
///////////////////////////////
// Why does `finally` exist? //
///////////////////////////////
try{
console.log("first");
return;
//this wont get called because of the return
console.log("second");
}finally{
//this WILL get called, and that is why finally exists
console.log("FINALLY");
}
//this wont get called because of the return
console.log("After everything");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment