18
Comments
  • 1
    If you are using JS, then you don't know who is yourself, right? :)
  • 1
    @skiilaa It's a constant battle for my sanity!
  • 2
    Is this an antipattern? I've been doing this for ages!
  • 0
    Wait a minute, self is not a reserved word in js rigth? So you will assign context/window object to self. Or is it? ..
  • 0
    Why is that bad?
    Only I use 'that' for this (pun intended)
  • 1
    @featurenotbug @Brachacz It's "bad" because you can use bind/call/apply to set context for functions since ES3. And since ES6 you can just use arrow functions.
  • 1
    There is a decent functional reason for doing this. If you are binding event handlers in inner methods, but still need a reference to the parent object, self will then reference the parent. You can get around this other ways. However just renaming "this" for the sake of it is beyond annoying.
Add Comment