127
rated 0 times
[
130]
[
3]
/ answers: 1 / hits: 41775
/ 6 Years ago, tue, january 9, 2018, 12:00:00
I'm using ES6 modules and am importing a variable from moduleA
into moduleB
:
//moduleA.js
let a = 5;
let b;
export { a, b };
//moduleB.js
import { a, b } from './moduleA'
a = 6;
b = 1;
But on change/assignment in moduleB
I'm getting error such as:
a = 6;
ReferenceError: a is not defined
On the other hand I can console.log(a)
in moduleB
.
It seems it is not possible to assign to imported variables? Is this true or am I missing the way to do it? Why is this not possible?
More From » import