Opening the book…
Code is read far more often than it is written — during reviews, debugging, extension, and the quiet re-reading you do to remember what you meant. A clever line that saves you thirty seconds today costs every future reader, including you, a minute each time they hit it. Optimizing for the writer is a false economy paid back with interest.
Prefer the clear version over the compact one: name intermediate values, split a dense expression into steps, choose the boring construct a newcomer will understand. When you catch yourself feeling proud of how tightly a line is packed, that is usually the moment to unpack it. Read your diff as if you'd never seen it, and smooth the parts that make you pause.
return u.filter(x=>x.a&&!x.d).map(x=>x.id);const active = users.filter(
u => u.isActive && !u.isDeleted);
return active.map(u => u.id);In genuine hot paths where profiling shows a real cost, readability sometimes yields to performance — but comment the trade-off so the next reader knows it was deliberate, not accidental.