Answer + explication π
.
..
β¦
β¦.
β¦..
β¦β¦
β¦β¦.
Answer: B
ο»ΏWhen you are dealing with βthisβ in a function, βthisβ value depends on how you are invoking the function. If you invoke a methods through an object, the this
value will be equal to this object! so when you are doing user.action() the value of this is equal to user!
But when you are doing const newFunction = user.action, you are storing the methods into a new variable, and when you are doing newFunction(), you are invoking the function without an object. So the value of βthisβ is undefined!
If you need to have the βthisβ value into newFunction you need to use apply to pass the context into the function, so if you are doing newFunction.apply(user) you will have β@Code__Ozβ!