js copay of array [...array] code example
Example 1: javascript duplicate an array
let arr =["a","b","c"];
// ES6 way
const duplicate = [...arr];
// older method
const duplicate = Array.from(arr);
Example 2: how to copy one array to another in javascript
// 1) Array of literal-values (boolean, number, string)
const type1 = [true, 1, "true"];
// 2) Array of literal-structures (array, object)
const type2 = [[], {}];
// 3) Array of prototype-objects (function)
const type3 = [function () {}, function () {}];