Skip to content

Instantly share code, notes, and snippets.

@traviswimer
Created April 24, 2013 05:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save traviswimer/5449838 to your computer and use it in GitHub Desktop.
Save traviswimer/5449838 to your computer and use it in GitHub Desktop.
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