Skip to main content
Journey Uncommon Logo
JourneyUncommon
hardJavaScripttop-level await orderingSingle-choice MCQ

Three ES modules use top-level await. Module X awaits a microtask, module Y has a fully synchronous body, and both import the same dependency. Given main imports X then Y, what is the console output order?

// dep.mjs console.log('dep evaluated'); // x.mjs import './dep.mjs'; await Promise.resolve(); console.log('X: after await'); // y.mjs import './dep.mjs'; console.log('Y: sync body'); // main.mjs import './x.mjs'; import './y.mjs'; console.log('main body');