Skip to content

Stew.first()

paige edited this page Nov 14, 2023 · 2 revisions

gets the first entry
type: Function

alt names:

  • front()
  • start()

arguments:

  • ?offset Number
    optional offset from the first index

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


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


console.log(arr.first());
console.log(arr.first(1));
const { Stew } = require('stews');


let obj = new Stew({ key1: "val1", key2: "val2", key3: "val3" });


console.log(obj.first());
console.log(obj.first(1));
"a" // offset of 0 gets the first entry
"b" // offset of 1 gets the second entry
{ key: "key1", value: "val1", index: 0 } // offset of 0 gets the first entry
{ key: "key2", value: "val2", index: 0 } // offset of 1 gets the second entry