Member-only story
Interview4: Hoisting & Dead Zone in Javascript
Deep Dive into Hoisting & Dead Zone in Javascript
You have read the Hoisting in JS and would like to solve hard questions of it. Here you go, the article will deep dive into the Hoisting concepts of Javascript. If you have any doubt, feel free to comment and expect a quick response.
Letโs start with a some simple example.
Question1:
function userData() {
return userData;
}
console.log(typeof userData()); Answer:
// Output: function;Question2:
function foo() {
let a = b = 0;
a++;
return a;
}
foo();
console.log(typeof a);
console.log(typeof b);Answer:
undefined
numberQuestion3:
function foo(x) {
x();
function x() {
console.log("foo");
}
}
foo(function() {
console.log("bar")
});Answer:
fooQuestion4:
let a = 10;
var b = 20;
console.log(a);
console.log(b);
console.log(window.a);
console.log(window.b);
console.log(this.a);
console.log(this.b);








