Last updated 2 years ago
JS ⟩ identifier ⟩ undeclared
assignment (=) to an undeclared identifier in sloppy mode will result in an accidental global variable in sloppy mode❗️
temporal dead zone
👉 related:class body has its own "this" context
typeof undeclared === "undefined" // true
assignment (=) to undeclared identifier will result in
accidental global variable in sloppy mode❗️ (in sloppy mode)
️ ReferenceError:'...' is not defined (in strict mode)
there is NO way to write a function to check if an identifer is declared.
// assume f is such a function f(undeclared) // ⛔ ReferenceError // JS will throw a ReferenceError on accessing `undeclared` // BEFORE you even have a chance to call f()❗
3 Ways to Check if a Variable is Defined in JavaScript ⭐️
typeof ⟩ Interaction with undeclared and uninitialized variables
ReferenceError: "x" is not defined
JavaScript check if variable exists (is defined/initialized)