4 ms·
I think a bit of context about `this` is important. Using `this` in a callback -- where you expect your caller to provide your local binding -- is straight-up
by donw 6y ago
I think a bit of context about `this` is important.
Using `this` in a callback -- where you expect your caller to provide your local binding -- is straight-up bad juju. Pass arguments instead.
Using `this` in an object instance to namespace is just fine. The entire point of having an object is that you get these nice encapsulated namespaces which can send messages to each other.
One suggestion, and a related ask: rather than just saying "Don't do FOO", provide alternatives as well; e.g., "Don't use `addEventListener`, use `superFooBarBazzer`".
Bonus points awarded for runnable examples. :)
Perhaps my biggest gripe about the entire Javascript ecosystem is finding libraries that provide documentation that looks like this:
// See how easy my library is to use!
myLibrary.doTheThing(fooBar, bazBang);
Without ever showing you what a `fooBar` or `bazBang` are, and perhaps where and/or how an enterprising developer might obtain one.
- austincheney 6y agohttps://github.com/prettydiff/share-file-systems https://github.com/prettydiff/share-file-systems 40k loc. I wrote an ESLint rule to error on this in both statements and expressions.