首先,上一段代码:

var f = function g() 
            {
                return 23;
                };
            console.log(typeof g);        //输出undefined
            //console.log(typeof g());    //没有输出  显示错误  “g”未定义
            console.log(typeof f);        //输出function
            console.log(typeof f());    //输出number

 

这里的g确实没有这种写法,输出undefined也是情有可原

 

对于下面两句话,我的理解是

f是函数,然后给f加一对小括号,即f(),就代表函数执行后返回的值。

这一点,我想可以从JavaScript函数的自调用执行来看的话,是可以解释的通的。

个人观点,欢迎留言讨论。

console.log(typeof f);        //输出function
            console.log(typeof f());    //输出number

相关文章:

  • 2021-08-16
  • 2021-04-08
  • 2021-08-16
  • 2021-08-25
  • 2021-05-26
  • 2022-12-23
  • 2021-12-30
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-09-04
  • 2022-12-23
  • 2022-12-23
  • 2021-10-09
  • 2021-12-05
相关资源
相似解决方案