Created
April 24, 2013 05:31
-
-
Save traviswimer/5449838 to your computer and use it in GitHub Desktop.
The purpose of finally (as in try{ }finally{ })
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/////////////////////////////// | |
// 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