wait until a function finishes javascript

Solutions on MaxInterview for wait until a function finishes javascript by the best coders in the world

showing results for - "wait until a function finishes javascript"
Matías
15 Jan 2020
1function firstFunction(_callback){
2    // do some asynchronous work
3    // and when the asynchronous stuff is complete
4    _callback();    
5}
6
7function secondFunction(){
8    // call first function and pass in a callback function which
9    // first function runs when it has completed
10    firstFunction(function() {
11        console.log('huzzah, I\'m done!');
12    });    
13}