简体   繁体   English

JS中的自动分号插入会影响第一个{在新行上的循环吗?

[英]Does automatic semi-colon insertion in JS affect for loops with the first { on a new line?

Will JS auto semi-colon insertion place a semi-colon at the end of for(...) like I've placed in the following example or is it safe to break the bracket onto a new line with for loops? JS自动分号插入是否会在for(...)的末尾放置一个分号,就像我放在下面的例子中一样,或者将括号拆分到带有for循环的新行是否安全?

for(...);
{
   ...
}

I've found plenty of info saying what is affected, but nothing specific to my question, which leads me to believe it may not be affected, but I would like to find a concrete answer. 我发现有很多信息说明了什么是受影响的,但我的问题没有什么特别的,这让我相信它可能不会受到影响,但我想找到一个具体的答案。

Personally, I prefer not to break onto a new line with brackets like this but the question has been raised ;) 就个人而言,我宁愿不打破像这样的括号的新行,但问题已经提出;)

Such a for loop is safe. 这样的for循环是安全的。 Semicolons will never be inserted in places where they would create empty statements. 分号永远不会插入到创建空语句的地方。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为什么要在JavaScript中添加自动分号(ASI)? - Why was automatic semi-colon insertion (ASI) added to javascript? 如何用html中的新行替换分号<td>特定的模型属性内容? - How to replace the semi-colon with new line in html <td> of the particular model attribute content? 为什么出错“;” 当不需要分号时,预期会在我的app.js文件中发生吗? - Why does error ';' expected occur in my app.js file when no semi-colon should be necessary? 返回并抛出一行,不带分号 - Return and throw on one line without semi-colon 我是一个非常新的编码器,它说缺少分号 - I am a very new coder and it says missing semi-colon 在 Javascript 中,用分号“return;”返回什么意思是 - In Javascript, what does return with semi-colon 'return;' mean YUI Compressor特殊注释在JS中添加分号 - YUI Compressor special comments adding semi-colon in JS 第三个引号中有一个半殖民地,引号显示正确,但没有正确推文。 它在分号处截断 - There is a semi -colon in the third quote, and the quote displays correctly, but does not tweet correctly. It truncates at the semi-colon 如何迭代javascript行分隔的字符串,检查分号分隔的第一个值,并加入值相等的行? - How to iterate over a javascript line delimited string, check the semi-colon delimited first value, and join lines where value is equal? JSLint缺少分号 - JSLint Missing Semi-colon
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM