Skip to content

Instantly share code, notes, and snippets.

@addityasingh
Last active April 10, 2016 19:44
Show Gist options
  • Save addityasingh/d3535ee4ac83842fd2aa5d5926ee85a6 to your computer and use it in GitHub Desktop.
Save addityasingh/d3535ee4ac83842fd2aa5d5926ee85a6 to your computer and use it in GitHub Desktop.
Try catch do not introduce block scope for new declarations
(function () {
'use strict';
try {
undefined();
} catch (err) {
var a = 5;
console.log(a); // 5
console.log(err); // TypeError: undefined is not a function(…)
}
console.log(a); // 5 This should be undefined if a was scoped only to catch block. But it isn't.
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment