On Fri, Oct 29, 2010 at 9:27 AM, Fabian D <[email protected]>wrote:
> > > On Oct 28, 4:42 pm, Ryan Florence <[email protected]> wrote: > > > or ... function(){ /* stuff */ }.bind(this) > > Isn't that the way to go? I mean the "that = this" approach seems a > bit outdated to me. For me, it's all about use cases - bind is used when I want to pass a function around, which was created elsewhere (like a function that is a part of a class). But as a whole, I find bind to be less readable (it's much less obvious to whom the this refers to), and also harder to maintain (IMO). As a side note, I believe it's a bit heavier performance wise, but I haven't run any benchmark on it. It also, as Sanford mentioned, allows multiple this references (for example - if I pass that function as an event to an element - it allows both referencing the element and the parent scope). -- Arieh Glazer אריה גלזר 052-5348-561 5561
