Answers for "Javascript promise resolve async"

1

Javascript promise resolve async

Promise.resolve([1, 2, 3]);
Is Promise.resolve() asynchronous?

No that's just a regular function call. It will return a result immediately.

Or is .then asynchronous or even both functions

No. Both aren't asynchronous in the sense that

promise1.then((value) => console.log(value));
will immediately return a new Promise for chaining.

However a Promise definitely resolves asynchronously, which means that the inner function (value => console.log(value)) is called definitely after your whole synchronous code executed.

Is there some other mechanism playing under the hood?

Yes there is a "magic" event loop in the background which manages all the async events.
Posted by: Guest on July-30-2021

Code answers related to "Javascript promise resolve async"

Code answers related to "Javascript"

Browse Popular Code Answers by Language