var obj = {n:1};
var obj2 = obj;
obj2.n = 2;
console.log(obj.n) //2
var obj = {n:1};
function fn1(a){
a.n = 3; //将obj处的n的值改成了3
}
fn1(obj.n); //2
var obj = {n:1};
function fn2(a){
a = {n:4}; //只是改变了a;但是并没有改变obj的指向
}
fn2(obj.n); //1
var a = {n:1};
var b = a;
a.x = a = {n:2};
console.log(a.n,b.n) //2,1
console.log(a.x,b.x) //undefined,{n:2}