Answer the question
In order to leave comments, you need to log in
How to achieve waiting for the result of a function in an if statement?
function testFunc() {
async.series([
function(down) {
setTimeout(function(){
down();
}, 10000);
}
],
function() {
return true;
});
};
if(testFunc()) console.log('Result function: true');
else console.log('Result function: false');
Answer the question
In order to leave comments, you need to log in
You can also make it look completely synchronous with the help of generators (plus promises).
You can already safely use it in a node, plus getting rid of unlimited nesting and crap debugging.
habrahabr.ru/sandbox/67590
If it is simpler and without callbacks, then move this operator inside the function. Well, in general, google "Asynchronous JS".
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question