0
0
Javascriptprogramming~10 mins

What hoisting is in Javascript - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to declare a variable using hoisting.

Javascript
console.log([1]); var x = 5;
Drag options to blanks, or click blank then click option'
Ax
By
Cz
Da
Attempts:
3 left
πŸ’‘ Hint
Common Mistakes
Using a variable name that is not declared.
2fill in blank
medium

Complete the code to show hoisting with a function declaration.

Javascript
[1] sayHello() { console.log('Hello!'); } sayHello();
Drag options to blanks, or click blank then click option'
Aconst
Bvar
Clet
Dfunction
Attempts:
3 left
πŸ’‘ Hint
Common Mistakes
Using var, let, or const instead of function.
3fill in blank
hard

Fix the error in the code to demonstrate hoisting with var.

Javascript
console.log(a); [1] a = 10;
Drag options to blanks, or click blank then click option'
Alet
Bconst
Cvar
Dfunction
Attempts:
3 left
πŸ’‘ Hint
Common Mistakes
Using let or const which cause ReferenceError here.
4fill in blank
hard

Fill both blanks to create a hoisted function expression and call it.

Javascript
var greet = [1]() { console.log('Hi!'); }; greet[2]();
Drag options to blanks, or click blank then click option'
Afunction
B()
C.call
D() =>
Attempts:
3 left
πŸ’‘ Hint
Common Mistakes
Using arrow function syntax without parentheses in call.
5fill in blank
hard

Fill all three blanks to create a hoisted variable and function, then call the function.

Javascript
console.log([1]); [2] greet() { console.log('Hello!'); } var [1] = 'Hello'; greet[3]();
Drag options to blanks, or click blank then click option'
Amessage
Bfunction
C()
Dvar
Attempts:
3 left
πŸ’‘ Hint
Common Mistakes
Using var instead of variable name in first blank.