在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()
原文地址:https://www.cnblogs.com/cupid10/p/15617814.html