JSFiddle - React, Tailwind, and code Playground

JavaScript

// Create promise wich resolves after a timeout of 0ms.
// This forces the promise to be enqueue in the event loop instead of executing immediately.
let promise = new Promise((resolve, reject) =>
  setTimeout(
    () => {
      console.log("[A] Inside Promise");
      resolve("DONE");
    }),
  0
);

// Add another message after promise has been resolved.
promise.then(
  result => console.log("[B] Promise returned: ", result),
  error => console.log("[C] Promise failed: ", error)
);

// Write to the console when this code block finshes executing.
console.log("[D] End of code");

// Output order: D, A, B