indexable-at
v1.0.1
Published
Polyfill for Array#at https://github.com/tc39/proposal-relative-indexing-method.
Downloads
5
Readme
indexable-at
polyfill for Array#at https://github.com/tc39/proposal-relative-indexing-method
Install
Install with npm:
$ npm install --save indexable-at
Usage
require('indexable-at');
const arr = [1, 2, 3, 4, 5, 6];
console.log(arr.at(1)); // 2
console.log(arr.at(-1)); // 6
const str = 'abcde';
console.log(str.at(1)); // 'b'
console.log(str.at(-1)); // 'e'
const int8 = new Int8Array([1, 2, 3, 4]);
console.log(int8.at(-1)); // 4