copy list javascript code example
Example 1: javascript copy an array
let arr =["a","b","c"];
const copy = [...arr];
const copy = Array.from(arr);
Example 2: copy array javascript
const sheeps = ['Apple', 'Banana', 'Juice'];
const cloneSheeps = sheeps.slice();
const cloneSheepsES6 = [...sheeps];
Example 3: javascript copy array
var oldColors=["red","green","blue"];
var newColors = oldColors.slice();
Example 4: how to copy one array to another in javascript
const type1 = [true, 1, "true"];
const type2 = [[], {}];
const type3 = [function () {}, function () {}];