⛔cannot access 'xxx' before initialization❗️
Last updated
Was this helpful?
Last updated
Was this helpful?
Was this helpful?
JS ⟩ error ⟩ ReferenceError ⟩ cannot access '...' before initialization
⛔ ReferenceError:cannot access '...' before initialization❗
replit:TDZ: let/const/class
using typeof on lexical declaration (let/ const/ class) in its temporal dead zone will throw a ReferenceError.
// ⭐ temporal dead zone (start)
// ------------------------------
typeof aLet; // ⛔ ReferenceError: Cannot access 'aLet' before initialization
typeof aConst; // ⛔ ReferenceError: Cannot access 'aConst' before initialization
typeof aClass; // ⛔ ReferenceError: Cannot access 'aClass' before initialization
typeof undeclared; // ❗ 'undefined'
// ⭐ lexical declarations (let/const/class)