Imports in ES modules are hoisted. What does that mean, and in what order do these modules run?
// a.js
console.log("a");
export const a = 1;
// b.js
import "./a.js";
console.log("b");
// main.js (the entry point)
console.log("main start");
import "./b.js";
import { a } from "./a.js";
console.log("main", a);
The answer
Answer it out loud first, the way you would in the interview. Then compare.
Checking your sign-in…