3 ms·
Even if you use semicolons, you still need the extra rule about return/throw statements. Otherwise the following will surprise you: return { property:
by spion 11y ago
Even if you use semicolons, you still need the extra rule about return/throw statements. Otherwise the following will surprise you:
return
{
property: value
};
(Whats the value returned? Its `undefined`)
Therefore, "Use a semicolon" is insufficient. Or rather, its about as sufficient as "Don't start a line with (".
Which means that the rule(s) for using semicolons are no more complex than the rules for not using them.
This is precisely why "follow these simple rules" is not enough. I believe that us programmers would really benefit if we stopped following and perpetuating best practices without understanding (and explaining) the reasons behind them very throughly.
If you want less cognitive overload, use a language with less warts, or a language with a type system. Lint-like rules that don't come with a reason are useless and result in a false sense of security