JS handler "this" value

Hello,

After building some UI for the past few days, I started writing some JS code to go with it. One thing I’m curious about is the this value for JS functions used as handlers. I can’t really tell what it is, and it doesn’t seem to be the binding context (which I could be retrieving using e.data, but it’s less convenient).

This makes it difficult to use JS classes and prototypal inheritance since there won’t be a reference to the instance of the current object available once inside the method itself.

For example: if I have a method on a class defined as ClassName.prototype.methodName = function (...) and I bind this method in a handler Handler="{methodName}", I have no way within the method to access the ClassName instance it was called on).

Hello!

This sounds exactly like what bind is for. :slight_smile: