Skip to content

Stew.append()

paige edited this page Nov 14, 2023 · 6 revisions

inserts a new entry at a given index
type: Function

alt names:

  • insert()
  • push_at()
  • push_to()

arguments:

  • index Number
    index to append at
    puts the appended entry infront of the index
  • key/value Any
    key or value to append
    for lists you only use the value
  • ?value Any
    optional value to append
    only used in pairs

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

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

arr.append(1, "b");

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

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

obj.append(1, "key2", "val2");

console.log(obj);
Stew(3) [ "a", "b", "c" ]
Stew(3) { key1: "val1", key2: "val2", key3: "val3" }