Hoisting behaviour of 'const' and 'let'
Mark S. Miller
erights at google.com
Sun Oct 12 10:36:53 PDT 2008
On Sun, Oct 12, 2008 at 8:52 AM, Mike Shaver <mike.shaver at gmail.com> wrote:
> On Sun, Oct 12, 2008 at 9:29 AM, David-Sarah Hopwood
> <david.hopwood at industrial-designers.co.uk> wrote:
>> - the hoisting behaviour of 'const' should be the same as 'let',
>> * it doesn't need to hoist for backward compatibility, unlike 'var';
> Not for compatibility with the standard, but const as implemented in
> at least 2/4 (not sure about JSCore) hoists, I believe.
Since IE rejects const, cross-browser web pages don't currently use
it. Both the ES3.1 effort and the Harmony effort have not taken
compatibility with existing browser const behavior as constraining on
the standard. ES3.1 does take on the "parse on 3/4 browsers"
constraint, but this constrains only syntax, not scoping or semantics.
Both the "const hoists to block start" currently in draft ES3.1 and
the "const doesn't hoist" that David-Sarah proposes would be equally
incompatible with existing browser semantics and equally compatible
with existing browser syntax.
More information about the Es-discuss