3 ms·
Not an incorrect article, but my opinion is that the focus should be informing people to not use this at all and more education on immutable data vs confusions
by sbr464 9y ago
Not an incorrect article, but my opinion is that the focus should be informing people to not use this at all and more education on immutable data vs confusions on this
- ryan-allen 9y agoI agree, I only use this in classes in JS, outside of that usage I see it as an anti-pattern.
- mikekchar 9y agoThe one place I've used "this" outside the context of a class is when I built a monad as an object and decided to use set the "this" context to be the monad. So, for example "return/unit/pure" (or whatever you want to call it :-) ) is available as "this.return". In that way the functions passed to "bind" can be generic and still build the correct monad. There are other ways to do it, but this struck me as the first time I had fiddled with "this" and felt that it was a reasonable idea.