Some time ago on the I've been asked about dead zone exception
in javascript, I didn't know what it is so started googling.

Ok, so there is no any kind of Exception
called DeadZoneException
like java's NullPointerException
. Ok so maybe the guy who ask, was about Temporal Dead Zone
, so I don't know this either, let's check what that is.
As stackoverflow
shows:
console.log(aVar); // undefined
console.log(aLet); // causes ReferenceError: aLet is not defined
var aVar = 1;
let aLet = 2;
So, as spec says let
and const
are hoisted but if you're accessing them before declaration you won't get undefined
as with usual var
but you'll get RefferenceError
. Nice.
So, TIL what is Temporal Dead Zone