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

I speculate that this is because Javascript takes stuff from Self where loops are functions.

So probably Javascript was meant to write something like: while(function(k) { ++i; return i < k; });

where the while function would call the closure until it got false at which point the while function itself would return so having var declarations be hoisted was not a problem in this syntax because everything (including if and while) would have its own scope due to being a function




You could have designed a language like that, but Brendan didn't.




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

Search: