JavaScript 中的单行语句需要大括号吗? - Are braces necessary in one-line statements in JavaScript?

问题:

I once heard that leaving the curly braces in one-line statements could be harmful in JavaScript.我曾经听说在单行语句中保留大括号在 JavaScript 中可能是有害的。 I don't remember the reasoning anymore and a Google search did not help much.我不记得推理了,谷歌搜索也没有多大帮助。

Is there anything that makes it a good idea to surround all statements within curly braces in JavaScript?在 JavaScript 中,将所有语句括在花括号内是否是一个好主意?

I am asking, because everyone seems to do so.我问,因为每个人似乎都这样做。


解决方案:

参考一: https://en.stackoom.com/question/K7za
参考二: https://stackoom.com/question/K7za
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章