3 ms·
I can understand not liking `this` in JavaScript, but it seems optimistic to say you never need it. If nothing else, you are bound to encounter large amounts of
by Silhouette 8y ago
I can understand not liking `this` in JavaScript, but it seems optimistic to say you never need it. If nothing else, you are bound to encounter large amounts of code that uses it, so being familiar with its behaviour is necessary to understand that code.
- DonHopkins 8y ago"... but it seems optimistic to say you never need it. If nothing else, you are bound to encounter large amounts of code that uses it" Wait -- JavaScript now supports "it"??! Can you iterate over "them"? At least it's not gendered, so you need to use "him" and "her" and "it" depending on the object's gender, or just keep everything in a collection so you can use "them".
- josephg 8y agothis also has some really fun rules that are useful for mad science sometimes. For example, you can recover the JS context's global value via this: (function() { return this })() In a browser this resolves to the window object. In nodejs it resolves to the global object. I've used this a few times to help write isomorphic javascript bundles, though its much less useful than it once was.