简体   繁体   English

为什么jslint hightlight ++?

[英]Why does jslint hightlight ++?

I have the following code: 我有以下代码:

for (i = 0; i < json.AnsData.length; i++) {

jsLint is telling me: jsLint告诉我:

Warning 96  JS Lint: Unexpected '++'.

Does anyone know why this is? 有人知道为什么是这样吗?

From http://www.jslint.com/lint.html : http://www.jslint.com/lint.html

The ++ (increment) and -- (decrement) operators have been known to contribute to bad code by encouraging excessive trickiness. 众所周知,++(递增)和-(递减)运算符会通过鼓励过度的技巧而导致不良代码。 They are second only to faulty architecture in enabling to viruses and other security menaces. 在支持病毒和其他安全威胁方面,它们仅次于错误的体系结构。 Also, preincrement/postincrement confusion can produce off-by-one errors that are extremely difficult to diagnose. 同样,增量前/增量后的混淆会产生难以诊断的一对一错误。 There is a plusplus option that allows the use of these operators. 有一个plusplus选项允许使用这些运算符。

JSLint is very strict and reflects the views of its author, Douglas Crockford. JSLint非常严格,并反映了其作者Douglas Crockford的观点。 Crockford is awesome, but he's also very opinionated and some people find his opinions go too far for their tastes. 克罗克福德(Crockford)很棒,但他也很自以为是,有些人认为他的意见对他们的口味而言太过分了。 If you find that avoiding ++ isn't something you can get behind, try JSHint instead of JSLint (or set the option in JSLint to tolerate ++ ). 如果发现不能避免++ ,可以尝试使用JSHint而不是JSLint(或将JSLint中的选项设置为允许++ )。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM