我试图返回async.map
的最终值,而不是console.logging。不幸的是,return
语句永远不会运行:
var square = function (num, doneCallback) {
return doneCallback(null, num * num);
};
// **Works**
async.map([1, 2, 3, 4], square, function (err, results) {
console.log("Finished!");
console.log(results);
// return results;
});
// **Not Working**
async.map([1, 2, 3, 4], square, function (err, results) {
console.log("Finished!");
// console.log(results);
return results;
});
我如何return
结果而非使用console.log
?