The problem seems not to be clear, but let's assume you want
doJob1() { /* Callback function includes */ } to execute this function first
doJob2() { /* Callback function includes */ } to execute second, after doJob1() is completed
doJob3() { /* Callback function includes */ }at last this doJob3() to execute.
Here then instead of executing line by line, execute 2nd function doJob2() after only doJob1() using Promises(precisely to be Promise Chaining). Similarly, doJob3() after doJob2() is completed.
new Promise(function(resolve, reject) {
//Code for executing function doJob1()
}).then(function(result) {
#when doJob1() is finished.
return new Promise((resolve, reject) => {
//Code for executing function doJob2()
});
}).then(function(result) {
#when doJob2() is finished.
return new Promise((resolve, reject) => {
//Code for executing function doJob3()
});
}).then(function(result) {
#when doJob3() is finished.
});
About Promises go through
About Promises
About Promises Chaining Promises Chaining