2 ms·
> I almost never use `this` and therefore don't remember all of its nuances. My team specifically avoids using it because it is harder for junior devs to grasp
by eyelidlessness 9y ago
> I almost never use `this` and therefore don't remember all of its nuances. My team specifically avoids using it because it is harder for junior devs to grasp and makes things harder to read. I tend to agree.
Honestly I think `this` (and any OOP technique) should be avoided except under very specific circumstances, regardless of whether junior devs are involved. Exceptions include (but are not limited to):
- Interaction with native APIs or legacy libraries which mandate its use
- React lifecycle or other modern lib equivalent, if absolutely necessary
- When using a `class`, and only if it would be substantially more clear than a functional alternative
> Writing a reduce function? That's what I use lodash for.
Unless you need it for non-`Array` collections, just use `Array#reduce`.
> The event loop? I know what it is but I have never needed to know what it is.
Every time you do anything asynchronously in JS, you are interacting with the event loop. It would be a good idea to familiarize yourself with it, to understand the constraints and performance impacts of single-threaded asynchrony.