Nicholas Jamieson
1 min readJul 7, 2018

--

… but if inside this.method you have a reference to this, you get the unexpected behavior (unexpected context object) …

Yes, that is why it’s not redundant: the behaviour is different. Nothing in the article stated that passing this.method instead of e => this.method(e) would not work — as long as the this context was not relied upon. Rather, the article highlighted some maintenance risks associated with the practice.

Another way to look at it is that implementing method as a non-static method is unnecessary in the first place, if it doesn’t rely upon the this context. Just implement it as a stand-alone function and pass it directly — i.e. without the arrow function.

--

--

Nicholas Jamieson
Nicholas Jamieson

Written by Nicholas Jamieson

RxJS core team member; front-end developer; mentor; speaker; open-source contributor

No responses yet