Well, first I should probably ask if this is browser dependent.
(好吧,首先我应该问一下这是否与浏览器有关。)
I've read that if an invalid token is found, but the section of code is valid until that invalid token, a semicolon is inserted before the token if it is preceded by a line break.
(我已经读到,如果找到了无效的令牌,但是代码段在该无效令牌之前一直有效,如果在该令牌之前加了换行符,则在该令牌之前插入一个分号。)
However, the common example cited for bugs caused by semicolon insertion is:
(但是,引用由分号插入引起的错误的常见示例是:)
return
_a+b;
..which doesn't seem to follow this rule, since _a would be a valid token.
(..似乎不遵循此规则,因为_a是有效令牌。)
On the other hand, breaking up call chains works as expected:
(另一方面,分解呼叫链可以按预期工作:)
$('#myButton')
.click(function(){alert("Hello!")});
Does anyone have a more in-depth description of the rules?
(是否有人对规则有更深入的描述?)
ask by T.R. translate from so
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…