如何区分深拷贝与浅拷贝,简单来说,假设B复制了A,当修改A时,看B是否会发生变化,如果B也跟着变了,说明这是浅拷贝,如果B没变,那就是深拷贝:我们先看两个简单的案例: //案例1(深拷贝) var a1 = 1, a2= a1; console.log(a1) //1 console.log(a2) //1 a2 = 2; //修改 a2 console.log(a1) //1 console.log(a2) //2 //案例2(浅拷贝) var o1 = {x: 1, y: 2}, o2 =…