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
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