The problem of changing one list and changing the other one accordingly
Problem Description
Using new list is equivalent to a list variable. If you change any list collection, the other list will also change accordingly.
This happens not only in js, but also in languages such as c#. The reason why this happens is due to data copy issues. Most of the time the pointer points to the address of the original array, so on the surface there are two codes, but in fact one is moving.
solve
js, c# can be solved through type conversion
//javascript
var list = [obj1,obj2,obj3,obj4];
var list2 = JSON.Parse(JSON.Stringify(list));
Convert object to string and then to Json object
//c#
var list = new List(obj);
list.Add(obj1);
list.Add(obj2);
list.Add(obj3);
list.Add(obj4);
var list2 = new List<obj>(list.ToArray());
Search for other solutions yourself.