Grokking Advanced JavaScript
0% completed
Hoisting
console.log(greet('Ana')); function greet(name) { return 'Hello, ' + name; }
Hello, Ana
The call on the first line works, although greet is declared below it. The reason is that JavaScript does not run a file or a function body strictly from top to bottom. It first prepares the scope, and only then runs the statements.
Two Phases: Setup, Then Execution
Before any line of a scope runs, JavaScript scans the scope for declarations and creates a binding for each name it finds
.....
.....
.....
Like the course? Get enrolled and start learning!
Reading Progress
0%