js----var a=b=2解析

var a=b=2

相当于:
  var a = 2;
  b = 2;//注意

 

<script>
    function sun(){
        var a = b = 2;
        console.log(a,b);
    }
    sun();
    // console.log(a);//a is not undefined
    console.log(b)//2 b为全局变量
</script>

 

posted @ 2019-02-20 10:42  SRH啦  阅读(983)  评论(0编辑  收藏  举报