I want to execute a callback when foreach has finished, but it's not working properly.How can I do that?
var response = [];
myArray.forEach(function(data) {
    data.asyncFunction(function(result) {
         response.push(result);
    });
}, function() {
    console.log(response); // Not being called.
});
console.log(response); // (Empty) Executed before foreach finish.
 
     
    