var x = 5;
(function() {
console.log(x);
var x = 10;
console.log(x);
})();
Output
undefined 10
Thanks for reading π
Follow @codedrops.tech for daily posts.
Instagram β Twitter β Facebook
Micro-Learning β Web Development β Javascript β MERN stack β Javascript
codedrops.tech
Top comments (3)
I think the variable becomes out of scope in the IIFE so maybe it returns
undefined
. Nice experiment!What help do you need?
Thanks :)