Proposal: Array.prototype.first() and Array.prototype.last()

Jeff Walden jwalden+es at
Wed Sep 28 03:52:59 UTC 2016

On 09/27/2016 05:38 AM, Bob Myers wrote:
> To my knowledge no-one has ever explained why the following is a bad idea:
> ```
> array.0
> array.-1
> ```

Consider this already-valid code:

  var first = array

This parses *right now* as

  var first = array;

So your proposal would break existing code.  We could imagine inserting a [no LineTerminator here] inside MemberExpression to permit "." NumericLiteral and "." "-" NumericLiteral to appear here, to be sure.  But that's extra complexity, extra ASI-handling (having worked on ASI handling recently, I assure you there's *nothing* simple about it, and further complicating ASI is a strong demerit in my book), all for IMO dubious value.


More information about the es-discuss mailing list