It is all about the call, it is not the definition of the function, it is not where the function is, none of that matters, it is only how the function was called that determines where the this keyword will be pointing to.
This isn't entirely true. You can bind a function and that sets this at creation time. Only new operator can change what this refers to on a binded function at call time.
This isn't entirely true. You can
bind
a function and that setsthis
at creation time. Onlynew
operator can change whatthis
refers to on a binded function at call time.Can you please elaborate, I am not able to understand. A link or something regarding the same will suffice.
If you
bind
a function:then no matter how you call the function (except
new
).You can use
.
:apply
orcall
:or even call it directly:
but
this
will always be the bound object:{type: "bound"}
.thank you so much for your assistance