Often, web developers are obsessed with brevity. There’s this thing were developers will try to write the same function in the fewest number of characters possible.
Personally, I think brevity is pointless. Readability is a lot more important.
Let technology handle that and focus on code that you can easily read when you (or someone else) comes back to it later.
What that means in practical terms:
- Use old-school function declarations or function expressions instead of arrow functions.
- Use if statements instead of ternary operators.
- Use lots of whitespace.
- Write lots of in-code comments and documentation.
I’ve also found that beginner developers find
Array.forEach() easier to understand than the methods like
filter() and so on, but that more seasoned developers find the latter methods more obvious.
That ones a gray area for me. I mix-and-match depending on what I’m trying to do.