If i create a variable in the catch block, is this block level scope?
It seems to create it in the global scope.
I thought it was block level because don't transpilers convert let statement to try/catch?
try {
throw Error("test");
} catch (e) {
var x = 15;
console.log(x);
}
console.log(x);
If i create a variable in the catch block, is this block level scope?
If you create a block scoped variable (using let) it is.
It seems to create it in the global scope.
You are using var which always creates the variable in the scope of the current function (or global if you aren't in a function).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With