Sitemap
Stackademic

Stackademic is a learning hub for programmers, devs, coders, and engineers. Our goal is to democratize free coding education for the world.

Interview4: Hoisting & Dead Zone in Javascript

Deep Dive into Hoisting & Dead Zone in Javascript

3 min readAug 17, 2024

--

Press enter or click to view image in full size
Author form shutterstock

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
number

Question3:

function foo(x) {
x();
function x() {
console.log("foo");
}
}

foo(function() {
console.log("bar")
});

Answer:

foo

Question4:

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);

Answer:

--

--

โœ… open src ๐Ÿš€ ๐Ÿš€
โœ… open src ๐Ÿš€ ๐Ÿš€

Written by โœ… open src ๐Ÿš€ ๐Ÿš€

1. Open source contributor, Architect at Jio Platform Ltd. and The Author of fe-pilot. https://github.com/opensrc0/fe-pilot/

Stackademic
Stackademic

Published in Stackademic

Stackademic is a learning hub for programmers, devs, coders, and engineers. Our goal is to democratize free coding education for the world.