Verbose when needed
There is a tendency to push for the smallest, most compact code at all times. But, that is a mistake.
!element
Boolean(element)
element === null || element === undefined
Even with ternaries, I use the one that makes sense in context.
const item = element.value || "missing"
const item = element.value ? element.value : "missing"
The major idea is that other humans can read and understand the code, not that it is written the best way for a computer or computer science course. Sometimes repeating the code may make the meaning and debugging simpler.
Written on June 2, 2020