What is hoisting in JavaScript?
January 6, 2025
Hoisting is a JavaScript behavior in which variable and function declarations are moved to the top of their containing scope (either global or function scope) during the compilation phase, before the code has been executed. This means you can reference variables and functions before they are actually declared in the code.
However, only the declarations are hoisted, not the initializations. This can lead to some surprising behavior, especially when dealing with variables.
No comments yet.