如何获取函数中return的值

 function a(){
  console.log(1)
  var i = 'hello'
   return function b(){
    console.log(2)
    console.log(i)
  }

}

var a =a();
console.log(a)//打印出来的就是b()函数

注意此时b函数没有执行,要想b执行,可以执行a()();

猜你喜欢

转载自www.cnblogs.com/psxiao/p/11373896.html