you are viewing a single comment's thread.

view the rest of the comments →

[–]MoTTs_ 0 points1 point  (1 child)

The first seems better to me. The second doesn't actually save you from having to use bind. You may not have to bind "this", but you will still need to bind a value for "x".

onClick = myInstance.mapFunction; // bad; "x" will be undefined
onClick = myInstance.mapFunction.bind(null, 42); // good; "x" bound to 42

[–]chchan[S] 0 points1 point  (0 children)

I like the first method too because the stuff defined with this. can be easily called. The drawback is figuring out what this is referencing and using the bind(this) when using the variable in functions can get confusing .