The importance of understanding the hoisting of JS engine


 

The output in the console would not be 21 or 20. Because girl has its own execution context. console.log(x) would not look for the global x.

When it executes the girl function. x is actually hoisted in the context of girl function but it is after console.log. So, the answer to this code would be undefined.

Social Media


Categories



All Posts



Contact Info