Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
if (foo) { bar; }
可以缩短为
if(foo) bar;
因为它只是块中的一个语句。
我想知道这是否同样适用于 try/catch ......我不喜欢我的代码中多余的东西。
根据 ECMAScript 5,需要一个块,这意味着您需要花括号。
http://es5.github.com/#x12.14
尝试语句: try Block Catch try Block Finally try Block Catch Finally 抓住 : catch ( Identifier ) Block 最后 : finally Block
尝试语句:
try Block Catch
try Block Finally
try Block Catch Finally
抓住 :
catch ( Identifier ) Block
最后 :
finally Block
http://es5.github.com/#x12.1
堵塞 : { StatementList opt } 声明列表: Statement StatementList Statement
堵塞 :
{ StatementList opt }
声明列表:
Statement
StatementList Statement