mirror of
https://github.com/xfarrow/javascript-tutorials.git
synced 2025-06-05 21:59:24 +02:00
update
This commit is contained in:
parent
11d149edc9
commit
04e200e406
@ -10,11 +10,11 @@
|
||||
|
||||
A Promise can be in one of these three states:
|
||||
- Pending (the operation is being processed)
|
||||
- Fullfilled (the operation has completed successfully)
|
||||
- Rejected
|
||||
- Fullfilled (the operation has completed successfully, resolve has been called)
|
||||
- Rejected (the operation has not completed successfully, reject has been called)
|
||||
*/
|
||||
const promise = new Promise(function (resolve, reject) {
|
||||
setTimeout(() => resolve('done'), 500);
|
||||
setTimeout(() => resolve('done'), 5000);
|
||||
});
|
||||
|
||||
/*
|
||||
@ -50,3 +50,9 @@ const promise = new Promise(function (resolve, reject) {
|
||||
promise.finally(
|
||||
() => console.log('The execution has terminated. Bye')
|
||||
);
|
||||
|
||||
/*
|
||||
This line is used to demonstrate that the code within "then, catch, etc."
|
||||
is in the event loop, as this is the first line getting executed.
|
||||
*/
|
||||
console.log("Last line");
|
@ -1,3 +1,4 @@
|
||||
JavaScript is single-threaded (but note that NodeJS is not entirely single-threaded, as it internally mantains a thread pool), but it can still take advantage of asynchronous programming.
|
||||
JavaScript is single-threaded (but note that NodeJS is not entirely single-threaded, as it internally mantains a thread
|
||||
pool), but it can still take advantage of asynchronous programming.
|
||||
|
||||
The Event Loop, which is a JavaScript construct that completes a new task while waiting for another
|
||||
The Event Loop, which is a JavaScript construct that completes a new task while waiting for another.
|
Loading…
x
Reference in New Issue
Block a user