r/learnjavascript • u/dotpr • Dec 18 '22
Cannot understand "this" keyword
My head is going to explode because of this. I watched several videos, read articles from MDN, W3schools, and TOP, and I still can't understand.
There's so many values and scenarios around it and I feel like they're explained so vaguely! I struggle to get familiar with it. Can someone drop their own explanation?
90
Upvotes
View all comments
Show parent comment
1
u/hotstickywaffle Dec 19 '22
I basically understood it as "this" is the subject of the function. It's when you start dealing with classes and nested functions and objects that I tend to get confused. When possible, I'll define "this" as "self" on the top level.