23
Making Sense of this and More
In this Chapter
Get a broader overview of the
this
keywordExplore solutions for ensuring
this
points to the right object by looking at approaches that involve arrow functions, redefiningthis
, and using thebind
method
In English, there are many situations where you need to refer to yourself:
I am hungry.
This teleportation device belongs to me.
I don’t know who microwaved the mustard.
I digress.
In JavaScript, things aren’t too different. We will write or encounter code where we need to refer to the current object in a very general way. The way we get a reference to this object is by the appropriately named this
keyword. We’ve seen this keyword a few times already, but now it’s time for us to look deeper ...
Get Javascript Absolute Beginner's Guide, 3rd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.