Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

Run a second function only after the first function is completely finished

function run2functions() {
    firstFunc(secondFunc);
}

function firstFunc(cb) {
    setTimeout(() => {
    },1000);
    cb();
    console.log("first one");
}

function secondFunc() {
    setTimeout(() => {
        console.log("second one");
    },1000);
}
 
run2functions();
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #Run #function #function #completely #finished
ADD COMMENT
Topic
Name
8+3 =