Since JavaScript is single threaded environment and there is Event Loop which is executing all the queued tasks, then why is [].forEach(() => {});
not executed asynchronously?
console.log("1");
[2].forEach(value => console.log(value));
console.log("3");
Output: 1 2 3
Why output will not be 1 3 2
Why callback function within .forEach
method is blocking the next line of code.