Javascript's lexical scoping and closure behavior are 100% conventional, there are no surprises here. There is only one message variable and it is referenced in both functions. Apparently the author wants the "message" assignment to work like a C macro and be evaluated at bind time, but I'm not aware of any language that has that behavior.
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.
Javascript's lexical scoping and closure behavior are 100% conventional, there are no surprises here. There is only one message variable and it is referenced in both functions. Apparently the author wants the "message" assignment to work like a C macro and be evaluated at bind time, but I'm not aware of any language that has that behavior.