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