0
JavaScript this question
var user = { name: "John", age: 30, sayHi() { alert(this.name); } }; var admin = user; user = null; admin.sayHi(); Why does it still has reference to admin object.??
5 Answers
+ 2
If you know the answer why are you asking?
+ 1
User is just a variable. When you assign user to admin, it gets copied and admin has the same values and doesn't refer to user.
https://code.sololearn.com/coqFdEmJyZ9W/?ref=app
0
Not exactly
0
It is not referring to admin , it is the copy which is being referred
0
We can't create copy of object this way