Skip to content

Soup.last()

paige edited this page Nov 14, 2023 · 2 revisions

gets the last entry
type: Function

alt names:

  • back()
  • end()

arguments:

  • ?offset Number
    optional offset from the last index

list: pair:
const { Soup } = require('stews');


let arr = new Soup([ "a", "b", "c" ]);


console.log(arr.last());
console.log(arr.last(1));
const { Soup } = require('stews');


let obj = new Soup({ 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