There are two different types of values in the ECMAScript variable: the base type value and the reference type value.
Base type value: Undefined, Null, Boolean, number, String
Reference type value: Object, Array, function, etc.
Simply put, declare an array A, then assign it to B, when modifying the value of B, if the value of a does not change, it is a deep copy, if the value of a changes together, then it is a shallow copy.
Some ways to implement deep copy of an array:
1. Syntax for using ES6
var a=[1,2,3]var [... b]=a; // or b=[...a]B.push (4); Console.log (b); // 1,2,3,4Console.log (a)//
2. Using the Concat () method
var a=[1,2,3]var c=[]; var b=C.concat (a); B.push (4); Console.log (b); // 1,2,3,4Console.log (a)//
3. Using the Slice () method
var a=[1,2,3]var b=a.slice (0); B.push (4); Console.log (b); // 1,2,3,4Console.log (a)//
4. Using the Stringify and parse methods of the JSON object
var a=[1,2,3]var c=json.stringify (a); var b=Json.parse (c); B.push (4); Console.log (b) ; // 1,2,3,4Console.log (a)//
Reference Address:
Https://www.cnblogs.com/echolun/p/7889848.html
Https://www.cnblogs.com/myzy/p/8561353.html
Some methods of JS to realize deep copy