Ok, my question is simple: In JavaScript / ES6
what happens when you have something like
x = 5;
console.log(x); // 5
is the interpreter automatically adding "let" at runtime or why is this working without errors?
Edit: Strict Mode The syntax of ES5 allowed for something called implicit globals, which have been the source of many frustrating programming errors. In short, if you forgot to declare a variable with var , JavaScript would merrily assume you were referring to a global variable. If no such global variable existed, it would create one! You can imagine the problems this caused.
I see. Thank you for all comments. I now understand why is this happening. Thanks!