Negative array index support <code>array[-1]</code> using ES6 Proxy
Negative array index support
array[-1]using ES6 Proxy
$ npm install --save negative-array
var negativeArray = require'negative-array';// adds negative array index support to any passed arrayvar unicorn = negativeArray'pony' 'cake' 'rainbow';// get the last item by using an negative indexconsole.logunicorn-1;//=> rainbow// OMG, YES!
This should go without saying; don't use in production.
MIT © Sindre Sorhus