從一個簡單例子來理解js引用類型指針的工作方式

<script> var a = {n:1};  var b = a;   a.x = a = {n:2};  console.log(a.x);// --> undefined  console.log(b.x);// --> [object Object]  </script> 上面的例子看似簡單,但結果並不好了解,很容易把人們給想繞了——「a.x不是指向對象a了麼?爲啥log(a.x)是un
相關文章
相關標籤/搜索