Hoisting is a JavaScript mechanism where variables and function declarations are moved to the top of their scope before code execution.
Variable hoisting
This means that, all undeclared variables are global variables.
In EcmaScript2015(ES6), let
and const
are hoisted but not initialized.
Function hoisting
Function expressions, however are not hoisted.
References: