0
0
Javascriptprogramming~20 mins

What hoisting is in Javascript - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
πŸŽ–οΈ
Hoisting Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate
2:00remaining
What is the output of this code involving hoisting?
Consider this JavaScript code snippet. What will it print to the console?
Javascript
console.log(a);
var a = 5;
Aundefined
B5
CReferenceError
Dnull
Attempts:
2 left
πŸ’‘ Hint
Think about how variable declarations are handled before code runs.
❓ Predict Output
intermediate
2:00remaining
What will this function print due to hoisting?
Look at this code. What is the output when calling foo()?
Javascript
function foo() {
  console.log(bar);
  var bar = 'hello';
}
foo();
Ahello
BReferenceError
Cundefined
Dnull
Attempts:
2 left
πŸ’‘ Hint
Remember that variable declarations are hoisted but assignments are not.
❓ Predict Output
advanced
2:00remaining
What is the output of this code with let and hoisting?
What will this code print to the console?
Javascript
console.log(x);
let x = 10;
AReferenceError
Bundefined
Cnull
D10
Attempts:
2 left
πŸ’‘ Hint
Variables declared with let are not hoisted like var.
❓ Predict Output
advanced
2:00remaining
What will this code output with function hoisting?
What does this code print when run?
Javascript
foo();
function foo() {
  console.log('Hi');
}
AReferenceError
Bundefined
CTypeError
DHi
Attempts:
2 left
πŸ’‘ Hint
Function declarations are hoisted completely.
❓ Predict Output
expert
2:00remaining
What is the output of this tricky hoisting example?
What will this code print to the console?
Javascript
console.log(typeof foo);
var foo = 'bar';
function foo() {}
Astring
Bfunction
Cundefined
DReferenceError
Attempts:
2 left
πŸ’‘ Hint
Function declarations are hoisted before variable declarations.