I would like to know that since objects on JavaScript work as references, how I still to get the properties values from a cloned object as shown below:
let user = {
name: 'Dan',
age: 26,
sayHi(){
console.log('Hi', this.name);
}
}
let user2 = user;
user.name = 'Suzan';
user = null;
console.log(user2.name);
//return Suzan
If object user received null, user2 shouldn't be null as well? Since they are pointing to the same memory addresses?