Event Loop
Understand the event loop
AdvancedTopic: Advanced JS
JavaScript Event Loop Program
This program helps you to learn the fundamental structure and syntax of JavaScript programming.
console.log('1');
setTimeout(() => console.log('2'), 0);
Promise.resolve().then(() => console.log('3'));
console.log('4');Output
1 4 3 2
Understanding Event Loop
Event Loop manages asynchronous execution.
Note: To write and run JavaScript programs, you need to set up the local environment on your computer. Refer to the complete article Setting up JavaScript Development Environment. If you do not want to set up the local environment on your computer, you can also use online IDE to write and run your JavaScript programs.