|
|
|
|
|
by mattchamb
4769 days ago
|
|
A nice article, I have been trying to learn more about javascript recently, and the section about "this" reminded me about a nice moment I had while tring to learn.
I used to get confused about how the "this" binding worked in javascript. My moment of clarity came when I tried to do something like this: someObject.someFunc = anotherObject.someOtherFunc; Doing this kind of thing didnt work with the conceptual model of "this" I had from my years of C# where functions are bound to objects.
Then I realised that ofcourse the object referred to by "this" would have to change, how else would it be implemented when you have first-class functions that can be passed around freely without a lexically captured "this"? Now I see as "this" more of an attempt to keep familiar syntax than something that fits with the semantics of the language. It really seems more of a call-context. |
|