我运行这个程序
function execute(someFunction, value) {
someFunction(value);
}
execute(function(word){ console.log(word) }, "Hello");
输出是 Hello
我没有在node.js官方文档中找到对单词的任何引用,它可能是在node.js中的关键词。
execute
需要一个回调和另一个参数。您将看到第二个参数传递给匿名函数。“ Hello”作为传递value
,value
然后传递到已定义word
为参数的回调中。
execute(function(word) { //<--the function is the "someFunction" parameter
console.log(word)
}, "Hello"); //<-- there is the "value" parameter
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句