CJCoding With Joseph
15free / daySign inCreate account
Back to Code Walkthrough

var Hoisting Inside a Function

JavaScript code walkthrough · Question 44
mediumFunctions

Code

Read carefully. What does this print?
1var x = 1;
2function f() {
3 console.log(x);
4 var x = 2;
5 console.log(x);
6}
7f();
8console.log(x);

Your answer