cf.completefrontend

ConceptHard

What happens when two ES modules import each other?

The code
// main.js (the entry point)
import { a } from "./a.js";
console.log(a);
 
// a.js
import { b } from "./b.js";
export const a = "a";
console.log("a.js sees", b);
 
// b.js
import { a } from "./a.js";
export const b = "b";
console.log("b.js sees", a);

The answer

Answer it out loud first, the way you would in the interview. Then compare.

Checking your sign-in…