I’m working with the Prototype JS library classes, which I’m really liking. But I ran into one stumbling block, Binding. In JS the scope in which your function can be called can change and as such the ‘this’ object can change. The main places this can happen is call back functions for events or anytime anonymous methods are used. Justin Palmer explains it really well here.
The above will bind the focusLine method to the _prompt object when the event callback is fired. The same thing applies for events within a custom defined Class.