This is not related to either Vue or imports, but to JavaScript, and more broadly, storing variables. In JavaScript (and other programming languages), variables are often either stored by value or by reference.
When stored by value, the address points to the actual value in memory, and this is how primitive values (Numbers, Strings, etc) are stored in JavaScript:
let x = 5; // Primitive, by value
By contrast, objects and arrays are stored by reference. That means that when you set another variable equal to your object reference, it will point to the reference, not the value itself:
let x = {
name: 'My Object'
}
let y = x;
console.log(x === y) // true
The true
result of the strict equality operator means they are the exact same object, not an original and a clone. Changing x
anywhere will also change y
, since they point to the same object.
Similarly, any code that imports an object will be importing a reference to it, and so will see any changes made to the object from elsewhere.