mirror of
https://github.com/xfarrow/javascript-tutorials.git
synced 2025-06-05 21:59:24 +02:00
Update event-loop.md
This commit is contained in:
parent
22cc0e4260
commit
0adc594656
@ -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
|
possible to execute now, it is put in the Event Loop. Let's look at some
|
||||||
examples:
|
examples:
|
||||||
|
|
||||||
1. ```javascript
|
1.
|
||||||
setTimeout(() => console.log('test'), 1000);
|
|
||||||
```
|
```javascript
|
||||||
`console.log('test')` will be put in the Event Loop.
|
|
||||||
|
setTimeout(() => console.log('test'), 1000);
|
||||||
|
|
||||||
|
```
|
||||||
|
console.log('test') will be put in the Event Loop.
|
||||||
|
|
||||||
|
2.
|
||||||
|
```javascript
|
||||||
|
|
||||||
2. ```javascript
|
|
||||||
const promise = new Promise(function (resolve, reject) {
|
const promise = new Promise(function (resolve, reject) {
|
||||||
console.log('test');
|
console.log('test');
|
||||||
resolve();
|
resolve();
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
console.log('test2');
|
console.log('test2');
|
||||||
});
|
});
|
||||||
|
|
||||||
```
|
```
|
||||||
`console.log('test2')` will be put in the Event Loop.
|
console.log('test2') will be put in the Event Loop.
|
Loading…
x
Reference in New Issue
Block a user