The standard is thick
so let’s begin with a very simple example. only 9 lines, only need
- function
- print a.k.a console.log
- new Promise <= we will talk about
- method call, here is .catch
- no setTimeout
so it just run through the res and rej
and out of the Promise, the catch works, catch the rej, no error
the procedure
so the function did execute, but not the job, which come into the event loop wait until free.
so it isn’t a builder pattern.
and the res and rej do some side effect, they enqueue the res and rej.
one more proof
the 5 will be print twice at the end 🙂