Hacker News new | ask | show | jobs
by makkerdam 4320 days ago
Second example in tip #2 is dead wrong. JavaScript does NOT do Dymanic Scoping.

I suspect he didn't even bother to run the code. His example throws an error when I try it: "ReferenceError: x is not defined" (as expected).

blind-leading-the-blind etc.

3 comments

The first example is wrong as well I believe - there is never a function call of bar.
I came here to say this.
While you're correct that the example is incorrect, technically speaking there are places where javascript does do dynamic scoping. Namely in a "with" or with "eval".
I had to read that paragraph several times to see if they said "But Javascript doesn't do this." Nope, not in there at all.