Skip to content

Instantly share code, notes, and snippets.

@jkup
Last active April 20, 2016 22:18
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 jkup/d622a3d284ebaa2da34552c6e4401865 to your computer and use it in GitHub Desktop.
Save jkup/d622a3d284ebaa2da34552c6e4401865 to your computer and use it in GitHub Desktop.
JavaScript try-catch
var a, b, c;
try {
b = 'foo';
a = nonExistent;
c = 'bar';
} catch(e) {}
console.log(a, b, c); // 'foo', undefined, undefined
@jkup
Copy link
Author

jkup commented Apr 20, 2016

Since all assignments before the first throw are executed, should you order assignments inside a try block by priority or likelihood of success?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment