Closure capture loop variables
deadalnix via Digitalmars-d
digitalmars-d at puremagic.com
Fri May 1 14:46:14 PDT 2015
On Friday, 1 May 2015 at 18:08:09 UTC, Adam D. Ruppe wrote:
> Javascript does D's current behavior, so I thought it was
> correct too, but C# doesn't it that way.
No it does not. In JS, var declare a variable at function level,
so that is why you see the behavior you see.
Since JS 1.7, you can declare scope level variable using let, and
they have the behavior of scope level variable (ie like in C#).
See
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/let
for reference.
More information about the Digitalmars-d
mailing list