I want to deep copy an array of integers in NodeJS. The first method I tried is
obj2 = JSON.parse(JSON.stringify(obj1));
However, it is so slow because it is a big array.
Now I am using
var l = obj1.length;
while (l--){
obj2.push(obj1[l]);
}
Though it is much faster, I am wondering if there exist better solutions? Thank you all!