5 hands-on exercises and 5 find-the-bug challenges for the JavaScript Hoisting lesson. Every one is checked automatically in the browser — write the code, run it, and the tests tell you what still fails.
Show what a var holds before its assignment line runs.
Call a declared function on a line above it and show the answer for 6.
Show the value only after the assignment line has run.
Show that a local var hides a global of the same name before it is assigned.
Add up a list with everything declared before it is used.
A function expression is not hoisted with its body.
Only the declaration is hoisted, never the value.
Ready to write the code?
The editor, the automatic checks and the worked solutions open up with an account.
Open the workspaceThe local var is hoisted, so the global is never seen.
The total is used before it is set up.
Assigning a function to a variable late means it is not there early.