Closed payne-chris-r closed 7 years ago
call
is a method on Function.prototype
that invokes the function, in this case goBoom
, on which it is called with the object passed set to this
, in this case deathstar
. So, it's equivalent to the following:
const goBoom = function () {
console.log(this);
};
let deathstar = { goBoom };
deathstar.goBoom();
// this === deathstar
but without actually making goBoom
a property of deathstar
.
Ok. I understand, but I think that sentence might create more confusion than it removes...
I'm not arguing that point, and I'd be happy to see a different explanation (maybe something based on my response to your query?) I'm just trying to address your WAT
I would read this as, "Call the function goBoom with deathstar as the context (this)"
Are we trying to clarify the README?
I'm more inclined toward @rts's wording than @payne-chris-r's at the moment.
@raq929's wording seems quite clear to me 🤖 .
Good. Than we're all in agreement. I like @rts' wording better too
This accidentally got reverted. 😞
I saw that! Noooo. #everythingIsNoLongerAwesome. But it can be again! #nextIteration.
How did this reversion happen?
My fault; I copied and pasted some of Chris's code from his training branch (or something like that), and I copied too much.
On Tue, Dec 6, 2016, 4:00 PM Jeffrey Horn notifications@github.com wrote:
How did this reversion happen?
— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/ga-wdi-boston/js-function-context-this/issues/24#issuecomment-265270726, or mute the thread https://github.com/notifications/unsubscribe-auth/ANRw2IOKKsN5dd0nnGfnQzkaZwYQi2h3ks5rFc0HgaJpZM4KQSPq .
Context:
this
refers to the passed object. Here you would say "the object receives the method".@gaand -- Why isn't it " Here you would say the method
call
receives the object as an argument"?