Regarding the code below, my goal is to break out of FOR LOOP B and continue with FOR LOOP A, but within a callback function.
for(var a of arrA) {
// ...
// ...
for(var b of arrB) {
// ...
// ...
PartService.getPart(a.id, function(err, returnObj) {
break;
});
}
}
Will this give me the results I want? If not, how can I achieve this?
EDIT 4/28/16 3:28 MST
- The callback function is indeed asynchronous
Based on one of the answers and all the comments below, without changing the scope of the question, perhaps the best question at this point is "How do I implement a synchronous callback function in Node.js?". I am considering refactoring my code so to remove for loops, but I am still curious if I can still go in this direction using synchronous callback functions. I know that Underscore.js uses synchronous callback functions, but I do not know how to implement them.