A new ES6 draft is available

Allen Wirfs-Brock allen at wirfs-brock.com
Sat Jan 17 11:16:46 PST 2015

On Jan 17, 2015, at 10:50 AM, Brendan Eich wrote:

> Fabrício Matté wrote:
>> I agree with Frankie. Assume a developer who has never seen this `new.target` construct before.
> In general, ES6 has new syntax, so this is a "learn it and use it" bump, one of many.

A general challenge in extending JS is that we can't  add new reserved words, so adding new meaning to existing reserved keywords in one way around that limitation.

Currently in ES6, the only reserved keywords that can appear immediately before a `.` are `this` and `super`.   Any other reserved word followed by a `.` is a syntax error.  So reserved words followed by period and an identifier is  one of the few available extension alternatives we have available.  And is a natural ready syntax think of new.target' as meaning give me the target value of the currently active `new` operator.

>> They will first think that this is an invalid expression, as `new` is an operator. Then, upon seeing this code execute, the natural question is "What is `new`?

hopefully they will say what is `new.target', "google it" and immediately find the answer.

>> Is it an identifier injected into Environment Records created by [[Call]] and [[Construct]]? Does this identifier resolve to an object (so that the MemberExpression would make sense)?"]

I suspect the hypothetical naive JS programmer postulated above wound't be aware of any of those concepts. That's why I explained in down thread without using them.

> new.target in the proposal (which does not yet have consensus) evaluates to an object, but (new) is a syntax error as in ES1-5.
> Yeah, it's a bit odd to grab new.identifier syntax-space and start by defining only new.target. Alternatives welcome. new^ already got an anti-grawlix reaction, new? did too (perhaps less but still).

> /be

Once this idea is in play, It also seems like a good solution for some other extensions we have grapple with.  Consider, for example:

This should be an interesting area of exploration for ES7 and beyond


More information about the es-discuss mailing list