I need know to whether a Promise
is executed synchronously or asynchronously. According to the mozilla docs, the promise
callback - executor function is executed immediately by the Promise
implementation.
But it does not seem to work like that to me according to the following code-
let myPromise = new Promise((resolve, reject) =>
resolve("Resolved from the promise");
);
myPromise.then(console.log);
console.log("After resolving the promise");
The log in the promise
then
handler gets printed after the log on the last line. Why it is executing like asynchronous way. Is I am missing anything?