Skip to main content

Hoisting differs per variable type

when hoisting fn declarations

hoisted with initial value set to actual function. (Block-scoped in strict-mode)

function declarations can be called before declared in code due to hoisting storing it in VE object before execution

when hoisting var variables

hoisted with init value of undefined. Function-scoped

!bug var hoisting is a common source of bugs!

Hoisting let & const variables

!technically Hoisted as <uninitalized\> via TDZ Block-scoped

Hoisting function expressions & arrows

depends on if var or let/const was used

References