JavaScript hoisting refers to the process where the compiler allocates memory for variable and function declarations prior to execution of code [1]. That means that declarations are moved to the top of their scope before code execution regardless of whether its scope is global or local. The code snippets below show hoisting in action: declare the function first and use/invoke it after.

2 Comments
Sort: