// At global scope
window.a = 42;
and var a = 42;
are same
Then why this runs perfectly
// At global scope
window.a = 42; // Creates binding in the outer global environment
let a = "answer"; // Creates binding in the inner global environment
console.log(a); // Shows "answer"
But it shows error
// At global scope
var a = 42;
let a = "answer";
Also for second case var a
would be assigned in global memory while let a
would be assigned in script memory.