Negative array index support
array[-1]using ES2015 Proxy
$ npm install --save negative-array
var negativeArray = require('negative-array'); // adds negative array index support to any passed array var unicorn = negativeArray(['pony', 'cake', 'rainbow']); // get the last item by using an negative index console.log(unicorn[-1]); //=> rainbow // OMG, YES!
This should go without saying; don't use in production.
- Node >=0.8.0:
node --harmony --harmony-proxies
- Chrome - with the this flag enabled
- Firefox >=12
MIT © Sindre Sorhus