Update event-loop.md

This commit is contained in:
xfarrow 2024-08-06 12:39:43 +02:00
parent 22cc0e4260
commit 0adc594656
1 changed files with 13 additions and 6 deletions

View File

@ -7,17 +7,24 @@ flow of execution. Whenever we meet a portion of code that may not be
possible to execute now, it is put in the Event Loop. Let's look at some
examples:
1. ```javascript
setTimeout(() => console.log('test'), 1000);
```
`console.log('test')` will be put in the Event Loop.
1.
2. ```javascript
```javascript
setTimeout(() => console.log('test'), 1000);
```
console.log('test') will be put in the Event Loop.
2.
```javascript
const promise = new Promise(function (resolve, reject) {
console.log('test');
resolve();
}).then(() => {
console.log('test2');
});
```
`console.log('test2')` will be put in the Event Loop.
console.log('test2') will be put in the Event Loop.