JavaScript Language feature Idea

Bruno Jouhier bjouhier at gmail.com
Tue Apr 19 05:17:06 UTC 2016


Why new syntax here? This is just a method that's missing: `array.last(n)`.

`array[-1]` would break things and it is difficult to find out where.
Consider:

``` javascript
for (var i = array.length - 1; array[i]; i--) doSomething(array[i]);
```

Not the best way to write such a loop but changing `array[-1]` would break
it.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20160419/25ed2965/attachment.html>


More information about the es-discuss mailing list