Discussion Archived [Question] Can't wrap my head around "this" function. (JavaScript)
submitted ago by tragicwhale
Posted by: tragicwhale
Posting time: 5.4 years ago on
Last edit time: never edited.
Archived on: 2/12/2017 1:51:00 AM
Views: 769
SCP: 9
9 upvotes, 0 downvotes (100% upvoted it)
Discussion Archived [Question] Can't wrap my head around "this" function. (JavaScript)
submitted ago by tragicwhale
view the rest of the comments →
[–] Cuddlefluff ago (edited ago)
I'm not any good at explaining things, but it's really quite easy once you "get" it. I have a long career of object oriented programming (C++, Java and C#), and
thisalso confused me a great deal in JavaScript in the beginning. It's not as intuitive and obvious as you'd expect. But it all boils down to whether or not you wrote a.-thiswould refer to the object on the left-hand side of the., If there is no.it would refer to the global scope akawindow. That's it, I don't know if I'm able to make it any clearer than that :P[–] tragicwhale [S] ago
haha, it's all good man, I'll just keep at it. I don't feel so bad knowing that it's not that intuitive. Thanks again.