Echo JS 0.11.0

<~>
mephju 2652 days ago. link 1 point
I never do this. If I need access to an object within a function I bind it as a param. I think this is much easier to reason about: fn.bind(null, myObject). If you use classes only sparingly there is no reason to ever change a function's context.

Replies

MaxArt 2651 days ago. link 2 points
bind gives us the basics of function currying, and while the same can be achieved with a higher order function, it's indeed nice to have it natively.

In JavaScript you should generally avoid the keyword this, but in some cases it makes sense. It's usually when we're dealing with component objects (ugh, so often in JSX).
xat 2652 days ago. link 2 points
Guess it depends on the situation. For example, Vue.JS binds methods to the instance of the component. That is a case where passing in the component instance as first parameter into the method would feel strange (at least to me).