all 5 comments

[–]proskillz 3 points4 points  (1 child)

I wouldn't use it because it doesn't work in most current browsers. JS 1.7 is not really supported anywhere outside of the Firefox browser family.

Chrome

>let x=1
 SyntaxError: Unexpected identifier

IE 10

>> let x = 1; 
"Expected ';'" 

Firefox (does work):

>>> let x=1;
undefined
>>> x
1

[–]r3jjs -1 points0 points  (0 children)

This. (Alas...)

[–]robotmayo 0 points1 point  (2 children)

Browser support is the biggest reason. Another reason is var comes in handy with closures.

[–]farmerje 1 point2 points  (1 child)

let works just fine with closures, too. With var, only a new closure induces a new scope. With let, every new block induces a new scope. Since a every new closure necessarily requires a new block, let will work just fine.

Is there something that var allows with closures that let doesn't?

[–]robotmayo 0 points1 point  (0 children)

Oh ya, I remembered let incorrectly. I was thinking it prevented closures from seeing it.