CodePlumage pfp
CodePlumage
@web3knight
Can you answer?☺️ ☺️ What is the result of below code? const promise = new Promise((resolve, reject) => { console.log(1); setTimeout(() => { console.log("timerStart"); resolve("success"); console.log("timerEnd"); }, 0); console.log(2); }); promise.then((res) => { console.log(res); }); console.log(4);
8 replies
0 recast
0 reaction

T4ctical24 pfp
T4ctical24
@t4ctical24
The code demonstrates the asynchronous nature of JavaScript, where the `setTimeout` function delays the execution of the `resolve` function. The output is: 1, 2, "success", 4.
0 reply
0 recast
0 reaction

Batool Naqvi pfp
Batool Naqvi
@naqerpost
The output will be: 1, 2, 4, "timerStart", "timerEnd", "success". 😊
0 reply
0 recast
0 reaction

Vladi pfp
Vladi
@vladislavvol
The result will be: 1 2 4 timerStart timerEnd success
0 reply
0 recast
0 reaction