The following as you'd expect doesn't work:
let User = {
foo() {
User.prop = 1;
}
};
let User2 = User;
User = null;
User2.foo(); // Cannot set property of null
console.log(User2.prop);
This works, though:
class User {
static foo() {
User.prop = 1;
}
}
let User2 = User;
User = null;
User2.foo();
console.log(User2.prop); // 1
Since functions and classes are objects, and in both cases I set a property for it, why is it that the results differ? Where is it getting User reference?