length-1

First negative index through Array

Usage no npm install needed!

<script type="module">
  import length1 from 'https://cdn.skypack.dev/length-1';
</script>

README

length-1 build status npm version

First negative index through Array

var getLengthMinus1 = require('./length-1');

// Arrays fixed
var arr = [1, 2, 3];
arr[-1]; // 3

// reusable tested functionality
Object.defineProperty(
  NodeList.prototype,
  -1,
  {get: getLengthMinus1}
);
document.querySelectorAll('#menu li')[-1];