console.log(a);
let a = 10;
var b = 100;
Output:
script.js:1 Uncaught ReferenceError: Cannot access 'a' before initialization
let a;
console.log(a);
a = 10;
console.log(a);
Output:-
undefined
10
Doubt:- While performing the first console.log(a), a is in temporal dead zone since it hasn't been initialized. So why is it not throwing any error and printing undefined?