On naming things (and meaning it)
Variable names are the smallest unit of documentation.
There are only two hard things in computer science: cache invalidation and naming things. I’ve made peace with the first one. The second one I obsess over.
A variable name is the smallest unit of documentation your codebase has. It’s read more often than any comment, any README, any wiki page.
The test
Read the name out loud. Does it make sense without context? If you need the surrounding code to understand what d or tmp or val means, you’ve failed the person reading this at midnight.
// bad
const d = new Date();
const tmp = users.filter(u => u.active);
// better
const now = new Date();
const activeUsers = users.filter(user => user.isActive);
The second version costs you a few more keystrokes. It saves everyone else hours.