script1.js
let log = "log";
function a() {
console.log(log);
}
export { a };
script2.js
import { a } from "./script1.js";
a(); // log
console.log(log) // Uncaught ReferenceError: log is not defined
Why does this work? Why does the function know what log
is even though log
is not defined?