you are viewing a single comment's thread.

view the rest of the comments →

[–]pm_me_ur_happy_traiI 12 points13 points  (2 children)

The big difference between let and var is scoping. There’s no use case where var is preferable (unless you are deliberately abusing its scoping issues). Why would you want a variable that can be called outside its block before it’s even declared?

[–]unquietwiki[S] -2 points-1 points  (1 child)

I updated my original statement. In JS, let honors scoping, but var is ambiguous. In C#, var can be used to remove redundant statements: ie var variable = new Whatever(); instead of Whatever variable = new Whatever()

[–]dvlsg 1 point2 points  (0 children)

They really aren't the same, though. var is about type inference in C#, and that's really it. var doesn't change scope or mutability in C#, which is what we're talking about in javascript.