使用参数在另一个函数中插入函数

Insert function inside another one by using parameter

如何通过输入将这个外部函数运行放在某个外部函数中?

function function1(a){
  a;  
}

somefunction(function (){
  $('#div1').hide();alert('hi');
});

如果要在outer function中输入external function执行external function,可以将external function的引用传递给outer function,然后调用outer function

中的函数

像这样:

function externalFunction(outerFunctionReference){
  // invoking the given function
  outerFunctionReference();
}

function firstOuterFunction() {
  console.log("Hello from the first outer function");
}

// passing the first outer function reference
externalFunction(firstOuterFunction);

// passing the second outer function reference
externalFunction(function secondOuterFunction() {
  console.log("Hello from the second outer function");
});