Hoisting is JavaScript's default behavior of setting aside memory for variable and function declarations before your code actually runs line-by-line.
βIt creates the illusion that declarations are physically "hoisted" (lifted) to the top of your code, though your source code isn't actually moved anywhere.
When JavaScript runs your code, it does so in two distinct phases inside the Execution
Memory Allocation Phase (Phase 1): The engine scans the code and stores variable and function declarations in memory.
Code Execution Phase (Phase 2): The engine executes your code line-by-line, assigning values and invoking functions.
Top comments (0)