FWIW, I tried very hard to come up with an example but failed. If I understand 
it correctly fat arrow acts is a helper for `var self = this`. Then it no 
matter what the underlying method does the following code will simply ignore 
`this`:

var self = this;

DOM.each("div", function (el) {
  self.doSomething();
});

Rewriting it using the new syntax:

DOM.each("div", (el) => {
  this.doSomething();
});

Correct me if I misunderstand how => works.

Anton 


On Thursday, May 31, 2012 at 7:42 PM, David Herman wrote:

> On May 31, 2012, at 6:06 PM, Rick Waldron wrote:
> 
> > The original API allowed me to pass an explicitly bound callback (whether 
> > it was by bind or fat arrow) and have that binding take precendence over a 
> > default behavior.
> 
> I think you might still be missing a key point: if `callbackFn` is a bound 
> function, there's no important difference in behavior between
> 
> callbackFn.call(elems, x, i)
> 
> and
> 
> callbackFn(x, i)
> 
> The former passes elems as a `this` parameter, but `callbackFn` ignores it 
> and uses its own bound `this`. The latter doesn't pass a `this` parameter, 
> and `callbackFn` uses its own bound `this`. Either way, you get the same 
> behavior. So you can simply replace lines 9 - 22 with
> 
> [].forEach.call( elems, callbackFn );
> 
> And there's no need for the isBound predicate.
> 
> Dave
> 
> _______________________________________________
> es-discuss mailing list
> [email protected] (mailto:[email protected])
> https://mail.mozilla.org/listinfo/es-discuss
> 
> 


_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to