I am trying to build a small javascript library for study purposes. I have an object inside a prototype that has some functions inside. I would like to access this
(the one that has valueOf
and stuff) from inside the functions, but this
now brings me only the object parent to the functions.
My code (coffee):
HTMLElement.prototype.on =
click: (action) -> @valueOf().addEventListener('click', action, false)
# I'd like this to work,
# but `this` here refers to the `on` object
Is this possible? I know I'm kinda reinventing the wheel, but as I said, it's for study purposes, so that's the idea.