JavaScript Language feature Idea

Biju bijumaillist at gmail.com
Sun Apr 17 18:53:01 UTC 2016


We cam make this simpler, in Javascript Array.slice() already accept
negative index.
Developers from Javascript and other languages are familiar with
negative value for index parameter.
So why cant we make array accept negative index.

in comparison with Bob Myers' proposal

> ```
> [1,2,3](-1)
> ```

will become

```
 [1,2,3][-1]
```

This will also allow us to set value using negative index,
example

var array_data = [1, 2, 3, 4];
array_data[-1] = 5;
array_data[-3] = 6;

// now array_data is [1, 6, 3, 5]


More information about the es-discuss mailing list