Hacker News new | past | comments | ask | show | jobs | submit login

What's the story behind `let` becoming the new `var`? Seems odd to me to change the short hand for "variable" to `let`.



`var` is still there, but it is scoped differently - `let` scopes to blocks, e.g. if (foo) { let baz = 'quux'; ... }

`let` in function scope is the same as `var`, in block scope it's narrow, it's basically the thing you want. `var` couldn't change, though, it would have broken existing code - hence `let`/


Math notation, Lisp. These are probably the inspiration for it.




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: