I have a question that if i want to make the for loop be sync.
because now my code will excute when for loop is done.
it will cause my function just work one time. Please tell me how can i edit it!
I have a question that if i want to make the for loop be sync.
because now my code will excute when for loop is done.
it will cause my function just work one time. Please tell me how can i edit it!
Have a look at the async Library http://caolan.github.io/async/docs.html#.each
async.each(openFiles, function(file, callback) {
// Perform operation on file here.
console.log('Processing file ' + file);
callback();
}, function(err) {
if(!err){
//because now my code will execute when for loop is done.
//code here will run only after loop is done
}
});