Object oriented JavaScript
Posted Nov 19, 2011 13:02 UTC (Sat) by
man_ls (subscriber, #15091)
In reply to:
Object oriented Lua by alankila
Parent article:
Awesome: A window manager that gets out of the way
It is especially annoying in callbacks: I would expect that this would be part of the function context as any other closure, but no: this points to the DOM node where the callback is running.
It can be worked around, of course: using a real closure, or calling the callback using weird call() techniques. But it makes for one of those "what were they thinking" moments. Same for prototypes, metatables' bastard son.
Frankly, JavaScript is surprisingly sane given that it was invented in 10 days.
(
Log in to post comments)