🔰hoisting
lifts identifiers to top of scope.
hoists identifiers to the top of a scope (at compile-time)
var hoisting - declaration hoisted, value initialized to "undefined".
let/const/class hoisting - declaration hoisted, value "uninitialized"❗️
const requires initialization - must have with initial value❗️
function hoisting - declaration hoisted, value initialized to a function.
lexical declaration ( let / const / class )
is "uninitialized" first (at compile-time).
then initialized to its initial value (when execution reaches its declaration at runtime)❗
there's a temporal dead zone between these two states, be aware❗
hoisting priority
function declaration is hoisted first (function hoisting).
Last updated
Was this helpful?