Medium
Understanding JavaScript Closure: How Variable Scope Works in Nested Functions
What will be logged to the console and why?
1const x = 1;2function outer() {3 const x = 2;4 function inner() {5 console.log(x);6 }7 return inner;8}910const fn = outer();11fn();