Soup.copy() - shysolocup/stews GitHub Wiki
creates a separate copy of the soup
type: Function
alt names:
- clone()
list: | pair: |
const { Soup } = require('stews');
let arr = new Soup([ "a", "c" ]);
let copy = arry.copy();
arr[1] = "b";
console.log(arr);
console.log(copy); |
const { Soup } = require('stews');
let obj = new Soup({ key1: "val1", key2: "val3" });
let copy = obj.copy();
obj[1] = "val2";
console.log(obj);
console.log(copy); |
Soup(2) [ "a", "b" ] // original
Soup(2) [ "a", "c" ] // copy |
Soup(2) { key1: "val1", key2: "val2" } // original
Soup(2) { key1: "val1", key2: "val3" } // copy |