simple-scopes.js 280 B

1234567891011
  1. //I should return `undefined` because y is bound to the inner-most enclosing function, i.e the nested one (bar()), therefore, it's undefined in the scope of foo()
  2. function foo() {
  3. function bar() {
  4. var y = 6;
  5. }
  6. bar();
  7. return y;
  8. }
  9. console.log(foo());