3 ms·
Is there a single instance in real JS code where it's this binding is actually useful?
by golergka 10y ago
Is there a single instance in real JS code where it's this binding is actually useful?
- jasonkostempski 10y agoIt depends on what the meaning of the word "it's" is.
- gbuk2013 10y agoYes - if you want to use this inside a callback within your function.
- golergka 10y agoOh, I wasnt being clear. I meant the default binding behaviour, not using .bind().
- gbuk2013 10y agoOne common example would be to refer to instance properties of an object from a method that is attached to the object's prototype. Actually I think using bind() would be a very unusual thing, but that could just be my style of writing code (I don't think I've ever used it in any code I have written over the years).