Stew.last() - shysolocup/stews GitHub Wiki
gets the last entry
type: Function
alt names:
- back()
- end()
arguments:
- ?offset
Number
optional offset from the last index
list: | pair: |
const { Stew } = require('stews');
let arr = new Stew([ "a", "b", "c" ]);
console.log(arr.last());
console.log(arr.last(1)); |
const { Stew } = require('stews');
let obj = new Stew({ key1: "val1", key2: "val2", key3: "val3" });
console.log(obj.last());
console.log(obj.last(1)); |
"c" // offset of 0 gets the last entry
"b" // offset of 1 gets the second to last entry |
{ key: "key3", value: "val3", index: 2 } // offset of 0 gets the last entry
{ key: "key2", value: "val2", index: 0 } // offset of 1 gets the second to last entry |