js array assignment to another array variable is a reference assignment, which can be passed using circular assignment, concat, and slice. But multi-dimensional array assignment, only cyclic assignment is reliable, slice and concat are not reliable, which god can give a detailed explanation, I am grateful.
var a = [1,2,3];
var b = a;
a.pop();
console.log(b); //1,2
/*=====================*/
var a = [[1,2],[2]];
var b = a.concat();
a[0][1] = 22;
console.log(b); //[[1,22],[2]]
//
Object.prototype.clone = function() {
var o = this.constructor === Array ? [] : {};
for (var e in this) {
o[e] = typeof this[e] === "object" ? this[e].clone() : this[e];
}
return o;
};