Here is my (simplified) constructor:
class User {
constructor() {
Object.assign(this, setup);
}
}
const setup = {
name: ''
}
export { User }
When I create a new object
import {
User
} from './User.js';
let user1 = new User();
user1 is what I expect.
If I declare user1.name = 'John' and then create another user let user2 = new User() then user2.name will be John, not an empty string.
Can someone explain why?
It appears setup is being changed and referenced instead of the new user object that was created.