![](/img/trans.png)
[英]What are the rules for JavaScript's automatic semicolon insertion (ASI)?
[英]Will this trigger ASI (Auto Semicolon Insertion)?
這會觸發ASI(自動分號插入)嗎?
if (abc === def) {
doSomething();
} // <-- here
else {
doDifferently();
}
try {
doSomething();
} // <-- here
catch(e) {
doCatch();
}
不可以。自動分號插入僅發生在語句之間,而您的示例並非如此。
if - else
語句是單個語句 。 在其中插入分號絕對沒有任何意義。 分號插入“功能”是所有關於未用分號分隔獨立的語句序列感。
否-您可以隨意設置花括號。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.