What is the output of following code? Also, please provide explanation for your answer.
setTimeout(() => console.log("First"), 0); console.log("Second");
In the console, first
"Second" will be printed, then
setTimeout works asynchronously. Even though the delay is 0 millisecond, in line 1, only the
setTimeout() invocation is happening. That does not execute the callback function passed to
Then in the second line
"Second" is printed. After that, the call stack is free to execute the callback function. So it executes and prints
"First" in console.