【发布时间】:2022-11-20 12:50:39
【问题描述】:
`When the function is passed with a parameter an error is returned that a is not a function while without parameter it executes and gives output=3
function one(d) {
return 1;
}
function two() {
return 2;
}
function invokeAdd(a, b) {
return a() + b();
}
console.log(invokeAdd(one(8), two));
【问题讨论】:
-
onereturns anumbernot afunction- use TypeScript -
You have to use
callbackfunction for the first argument in theinvokeAddlike this ->invokeAdd(()=>one(4) , two.
标签: javascript function parameter-passing