In the first case, I use export
and it behaves as I expect
App.js
import * as a from "./a.js";
console.log("a:", a.a); // it would print out "a: a1 "
a.js
let a = "a0";
export { a };
a = "a1";
In the second case, I use export default
, and it does not behave as I expect
App.js
import a from "./a.js";
console.log("a:", a); // it would print out "a: a0" ★★★
a.js
let a = "a0";
export default a;
a = "a1";
Why does this happen?