if (foo) {
bar;
}
can be shortened to
if(foo) bar;
since it's only one statement in the block.
I'm wondering if the same applies to try/catch... I don't like extra cruft in my code.
According to ECMAScript 5, a block is required, which means you need the curly braces.
https://es5.github.io/#x12.14
TryStatement :
try Block Catch
try Block Finally
try Block Catch Finally
Catch :
catch ( Identifier ) Block
Finally :
finally Block
https://es5.github.io/#x12.1
Block :
{ StatementList opt }
StatementList :
Statement
StatementList Statement
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With