I am a Java developer and beating my head to understand how JS calls function inside a function.
function mainFunction() {
//some HTTP Call. Callback is done through chaining. (Total execution time: 10s) -> (1)
//let b = some HTTP Call. Callback is assigned to local variable a. (Total execution time: 5s) -> (2)
//console.log("Hi") -- (3)
//Setimeout(500, ......); --(4)
// some very long piece of code - (Execution time: 60s) -- (5)
}
In timeline, what will be the order of execution of above code?
Do we have any difference (in wait) in Step 1 and Step 2?
Also do we have any difference if these http callbacks leverage AngularJS $http service?
3, 5, 4, 2, 1initis the initial call, andcbis the callback:1init, 2init, 3, 4init, 5, 4cb, 2cb, 1cb