In this simple code, since the variable b is a let variable and i am trying to log() its value, I was expecting a reference error that said: cannot access ‘a’ before initialization,
but instead i am getting the error:
Uncaught ReferenceError: a is not defined
console.log(a);
let a=10;
var b=19;
a screenshot of the code and the error–>
i ran the same code in online js editors and they give the expected error, i am confused now :
the same code on an online editor with different error
>Solution :
According to error docs it happens within any block statement
Since you don’t have block statement, JS fires another error.
I suppose that in online editor, the code is executed by another code, so there could be block statement outside the "file".
