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
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章