1,函数作为参数

通常把函数作为参数叫做回调函数

function fn1(fn) {
  fn();
}
fn1(function(){
   console.log("哈哈"); 
});

2,函数作为返回值

function fn1() {
    return function(){
      console.log("呵呵");
    }
}
fn1()();//调用
    function test(){
      return function(){
        console.log('哈哈');
      };
    }
    var res=test();
    console.log(res);
    res();

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-01
  • 2021-07-28
  • 2021-07-28
  • 2022-12-23
猜你喜欢
  • 2021-07-10
  • 2021-09-23
  • 2022-12-23
  • 2022-01-27
  • 2022-12-23
  • 2021-10-17
  • 2021-02-22
相关资源
相似解决方案