Darien Valentine (2017-07-23T07:36:21.000Z)
Here are some related threads from the past:

https://esdiscuss.org/topic/negative-indices-for-arrays
https://esdiscuss.org/topic/array-slice-syntax
https://esdiscuss.org/topic/javascript-language-feature-idea

I think I’ve seen it mentioned a few other times too.

The `arr[-1]` syntax is a non-starter I’m afraid, cause it’s just property
access. An array can already have a property with the key "-1".

Personally I’d find it weird for slicing to be singled out for special
syntax. It’s just a method. However I’d agree that it’s quite awkward to do
things like `arr[arr.length - 1]` or `arr.slice().pop()` etc to access from
the right. I think in one of those threads someone proposed a method like
`Array.prototype.nth()` which would accept negative indices, though this
creates an odd asymmetry since (presumably) we would not want to use -0 for
the last index.

In general I think the functionality you’re describing could be useful but
that it could be served better by adding methods rather than syntax.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20170723/adc5ef21/attachment.html>
valentinium at gmail.com (2017-07-23T07:37:52.252Z)
Here are some related threads from the past:

- https://esdiscuss.org/topic/negative-indices-for-arrays
- https://esdiscuss.org/topic/array-slice-syntax
- https://esdiscuss.org/topic/javascript-language-feature-idea

I think I’ve seen it mentioned a few other times too.

The `arr[-1]` syntax is a non-starter I’m afraid, cause it’s just property
access. An array can already have a property with the key "-1".

Personally I’d find it weird for slicing to be singled out for special
syntax. It’s just a method. However I’d agree that it’s quite awkward to do
things like `arr[arr.length - 1]` or `arr.slice().pop()` etc to access from
the right. I think in one of those threads someone proposed a method like
`Array.prototype.nth()` which would accept negative indices, though this
creates an odd asymmetry since (presumably) we would not want to use -0 for
the last index.

In general I think the functionality you’re describing could be useful but
that it could be served better by adding methods rather than syntax.