Javascript functions, call

Javascript functions call backs

This time I would like to talk about how easy it is to test if a javascript function it is done executing, by setting booleans

the next example will give you a good head start on how to do if you ever need this kind of algorithm


function doSomething() {
doSomething.complete = false;
// your code here
doSomething.complete = true;
}
doSomething.complete = false;

if (doSomething.complete) { // doSomething execution complete
// your code here
}

Since JavaScript is a single execution flow , so when a function it is call it will execute, so what we can do it is just put some events call, such as setInterval, if this bool becomes true, them the first function it is done so will be the green line to execute the next function