1 Promise.resolve([1, 2, 3]);
2Is Promise.resolve() asynchronous?
3
4No that's just a regular function call. It will return a result immediately.
5
6Or is .then asynchronous or even both functions
7
8No. Both aren't asynchronous in the sense that
9
10promise1.then((value) => console.log(value));
11will immediately return a new Promise for chaining.
12
13However a Promise definitely resolves asynchronously, which means that the inner function (value => console.log(value)) is called definitely after your whole synchronous code executed.
14
15Is there some other mechanism playing under the hood?
16
17Yes there is a "magic" event loop in the background which manages all the async events.