Because block-level scoping is a very good way to avoid certain bugs and is easier to reason about. Especially when considering project successors. Now, you cannot say that arguing that other languages have it is irrelevant. That is not the case because they have decided to so for good software engineering reasons. They could have easily had everything functionally scoped too but they don't. And bringing up your opinion that we don't need a feature that is currently in the spec is not helpful in this context because it is never going away, that would be an insane breaking change. *rant over* Otherwise, the for(;;) syntax seems like the best and most intuitive. Especially for how that would work actually. Question though, would the variable be available in an else or else-if block Sebastian Malton
how is any of this less-confusing than a simple style-guide of pre-declaring all variables @ the beginning of a function? again, there’s zero legitimate reason why _javascript_ even needs block-level scoping of variables (and arguing because other languages have it is not a reason). you're just creating more needless _javascript_ style-guide variance that further confuses your team-members / project-successor. ``` /*jslint bitwise: true, browser: true, maxerr: 8, maxlen: 100, node: true, nomen: true, regexp: true, stupid: true */ (function () { 'use strict'; // es5 best-practice of declaring all variables at beginning of function, // and runtime-checked by 'use strict' pragma var bar, c0, c1, foo, getTeamArray, people, v1, xx, yy; getTeamArray = function () { return [1, 2, 3]; }; people = getTeamArray(); if ( } else if ( } else if ( } else { } // output: it's a crowd 1,2,3 bar = function () { return 0; }; foo = function () { return 50; }; (function () { xx = foo(); if (xx < 50) { return; } yy = bar(); if (yy > 0) { return; } // else }()); // output: 50 0 c0 = null; c1 = function (xx) { return xx; }; v1 = false; // 'unset' xx xx = undefined; (function () { if (c0) { return; } xx = v1; if (c1(xx)) { return; } // else }()); // output: null false }()); ```
| ||||||
_______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

