loading...

What's the output? Hoisting question

318097 profile image Mehul Lakhanpal Originally published at codedrops.tech ・1 min read
var i = 5;
if(true){
  var i = 10;
}
console.log(i);

Thanks for reading 💙

Follow @codedrops.tech for daily posts.

InstagramTwitterFacebook

Micro-Learning ● Web Development ● Javascript ● MERN stack ● Javascript

codedrops.tech

Discussion

pic
Editor guide
Collapse
1qk1 profile image
Panagiotis Skarlas

Bruh this is scope, not hoisting.

(Also the answer is 5)

Collapse
318097 profile image
Mehul Lakhanpal Author

It is hoisting too. And the answer is 10

Collapse
1qk1 profile image
Panagiotis Skarlas

Oh wow. There is a reason var is deprecated haha. Sorry my friend, I'm an idiot.

Thread Thread
318097 profile image
Mehul Lakhanpal Author

No problem. Everyone was at situation once 😀