Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I'm pretty sure I understand lexical scoping, and this ain't it:

    function foo() {
      window.c = "really?"
      d = {};
      function bar() {
        var a = "var";
        {
          with (d) {
            var a = b;
          }
        }

        console.log(a);
      }

      d.b = c;
      bar();
    }

    foo();


You are of course correct about with() being dynamically scoped; thank you. I had forgotten about with() when I wrote what I wrote. I must weaken my claim to "JS is lexically scoped, except for the with() construct."




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: