<script type="text/javascript">
var a = {n:1};
var b = a; // 持有a,以回查
//a.x = a = {n:2};
a = a.x = {n:2};
console.log(a.x);// --> undefined
console.log(b.x);// --> {n:2}
</script>
a.x = a = {n:2};
a = a.x = {n:2};
<span style="color: rgb(102, 102, 102); font-family: "Helvetica Neue", Helvetica, Arial, "PingFang SC", "Hiragino Sans GB", "WenQuanYi Micro Hei", "Microsoft Yahei", sans-serif; font-size: 13px; background-color: rgb(246, 246, 246);">a = a.x = {n:2}和a.x = a = {n:2}的结果是一致的原因是,属性访问表达式优先级高于“=”号,无论哪种赋值方式都是先执行a.x,</span>
<span style="color: rgb(102, 102, 102); font-family: "Helvetica Neue", Helvetica, Arial, "PingFang SC", "Hiragino Sans GB", "WenQuanYi Micro Hei", "Microsoft Yahei", sans-serif; font-size: 13px; background-color: rgb(246, 246, 246);">所以a 指向是{n:1},添加属性x之后,被重新赋值{n:2}对象。</span>