|
|
|
|
|
by anonym
6554 days ago
|
|
Yes. I have to admit that this behavior confused me too when I was first learning Javascript. My only previous experience with lexical scope was in Common Lisp, which of course works the same way -- but the issue doesn't seem to come up as much there, perhaps because straight reassignment within the same lexical scope (of non-special variables) isn't something you do too often; perhaps because you can establish a new lexical scope and simultaneously rebind with LET within the normal control flow without defining and then calling a function, or perhaps simply for stylistic reasons). So I'd never really noticed it in Lisp. But once I realized what was going on it was clearly perfectly sensible. It's hardly "creepy," and it's certainly easy enough to establish new scope when you need to. And for crying out loud, it's not got anything at all to do with asynchronicity. |
|