Skip to content
Advertisement

Tag: asynchronous-javascript

Returning result from asynchronous function using callbacks

I have to write the body of a function getABC() which essentially has to take in responses from 3 different functions, getA()(synchronous),getB(callback)(callback driven),getC() (promise based). Ultimately I have to return a promise aggregating each function’s result, like [(result of getA),(result of getB),(result of getC)]. I am pasting the snippet of the code down below: ` I cannot edit any other

What’s the order of execution when we have callback inside promise?

I am new to JavaScript and, am not able to understand why the output of the following code:- is:- and not:- additionally, console.log(“async executed”) is not getting lagged for 10 seconds, instead, it gets executed immediately after the two synchronous console.log Answer As commented by @trincot, setTimeout is a function that immediately returns and execution will continue below it like

Advertisement