Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/cocoa/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Node.js module.exports函数是否带有回调?_Javascript_Node.js - Fatal编程技术网

Javascript Node.js module.exports函数是否带有回调?

Javascript Node.js module.exports函数是否带有回调?,javascript,node.js,Javascript,Node.js,我有这样一个函数: var theThing = fucntion(argumentArray){ //do the thing reutrn resultVar; } 我想把它做成一个模子,这样我就可以用它了 var myModule = require('mymodule'); myModule.theThing([arg1, arg2], function(result){ //handle results }) 我该怎么做 这里有一篇关于这方面的好文章 在va

我有这样一个函数:

var theThing = fucntion(argumentArray){
    //do the thing
    reutrn resultVar;
}
我想把它做成一个模子,这样我就可以用它了

var myModule = require('mymodule');
myModule.theThing([arg1, arg2], function(result){
    //handle results
})

我该怎么做

这里有一篇关于这方面的好文章

var theThing=function(argumentArray){
中,函数被定义为具有一个参数(数组值)

myModule.theThing([arg1,arg2],function(result){
中,使用两个参数调用函数,一个数组和一个函数


用一个参数定义一个函数并用两个参数调用它似乎是一个错误。

很棒的文章,带书签,谢谢!但是我实际上如何通过回调处理结果?在函数中创建一个回调参数,如果该参数存在,则调用该函数。..var myFunc=function(a,b,callDude){//do stuf if(callDude){callDude();}}myFunc(4,'cat',done);done将在传递时被激发-您可以选择何时在函数中激发done。