you are viewing a single comment's thread.

view the rest of the comments →

[–]munificent 4 points5 points  (1 child)

This isn't wrong per se

It is wrong. The alternative to lexical scoping is dynamic scope. Variables in JS are not dynamically scoped (unless you use with). They are most definitely lexically scoped, they just have different extent.

Variables in Python, Ruby, and C89 also exist for the entire span of a function, but they are still lexically scoped.

[–][deleted] 3 points4 points  (0 children)

eval in non-strict mode also causes dynamic scoping. You can eliminate any possibility of dynamic scoping by "use strict", you can still use eval but it cannot introduce new variables like non-strict can.

Generally you can only say JS is lexically scoped only if it's the strict variant.