在js中当var遇到赋值时函数

在js中当var遇到赋值时函数

赋值时函数提升的是var,函数并没有提升

    fn();   //fn is not a function
        //   console.log(fn)  //undefined
      var fn=function(){
      console.log(3) 
  };
  fn()

执行过程如下

    var fn;
    fn();   //fn is not a function
    ;fn=function(){
      console.log(3) 
  };
  fn()
posted @ 2020-04-28 12:18  Cupid05  阅读(507)  评论(0编辑  收藏  举报