预期输出:“x is 2” 实际输出:“x is undefined”
应用程序.js
var x = db_Save(req.session.user);
console.log('x is ' + x);
dbFile.js
var db_Save= function (user) {
// return 2; /* 'x is 2' would print;
console.log('function returns "undefined" before following');
userProfile.find({Email: profileInstance.Email}, function(err, doc){
console.log('prints after "x is undefined"');
return 2; // does not get returned
});
}