On Tue, Oct 1, 2013 at 7:35 PM, Andrea Giammarchi <andrea.giammar...@gmail.com> wrote: > setTimeout accept extra arguments ... I write JavaScript that uses this > feature. > > `setTimeout(callback, delay, arg1, arg2, argN, evenAnObject);` > > so fat arrow does not solve much here, I can use self as first argument and > I am good. > > `forEach` and all other arrays accept a second argument > > `array.forEach(doStuff, boundContextObject);` > > so fat arrow does not solve a thing in mostly all Array extras.
Having the capability to set 'this' (or pass the current this as a plain argument) doesn't make it any more convenient. 'this' still isn't captured by the closure like every other variable is, which is confusing. As David said, being forced to pollute the signature of every standard callback-taking function with this argument is just silly. As Claude and others have said, the silly 'this'-rebinding kludges we have to adopt *everywhere* just to work around this feature of JS are ridiculous and fragile. Automatic 'this' binding is very convenient in some places. In others, it's very inconvenient. Arrow functions give us something better suited for those latter cases. > for **DOM** I use handlers as specified by **W3C** so that `{handleEvent: > function () {this}}` works better than any mess I could create with > callbacks that I won't be unable to remove later on (as I've said) ... Virtually nobody does this, and newer interfaces specified with the WebIDL 'callback' type don't accept it at all. > so I > can use `removeEventListener(this)` in every method handled by that object. I didn't mention event listeners, actually. There are lots of other things that take callbacks besides event listeners. > So I actually wonder what kind of JavaScript **you** write because this was > a honest question but probably ... people not familiar with JS are the > answer: since developers ignore part of JS specs available since every then > we need a fat arrow to break old syntax to make the creation of self bound > function easier. > > This would be already an answer so thanks for participating. Wow, that's pretty rude. ~TJ _______________________________________________ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss