Suppose i have a var.js
export let x = 1;
export const f = () => x = 5;
Then i execute this in another file
import { x, f } from './var.js';
console.log(x); // 1
f();
console.log(x); // 5
Why is the imported variable x
able to change accordingly?
Does import { x }
gets re-evaluated when x
in var.js
changes?
Or is x
a reference to the original x
in var.js
rather than a copy?