In order to duplicate an array in JavaScript: which of the following is faster to use?
###Slice method
var dup_array = original_array.slice(); <
var dup_array = original_array.slice();
You can follow this code. Immutable way array clone. This is the perfect way to array cloning
const array = [1, 2, 3, 4] const newArray = [...array] newArray.push(6) console.log(array) console.log(newArray)