jslint中出现意外的'++' [英] Unexpected '++' in jslint

查看:117
本文介绍了jslint中出现意外的'++'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


可能重复:

为什么要避免在JavaScript中增加(>”)和减少(& - )运算符?

意外的++” jslint中的错误

jslint.com给我错误:

jslint.com is giving me the error:

Unexpected '++'.

此行的

for this line:

for (i = 0; i < l; ++i) {

我试过 i ++ 但是没有去。

推荐答案

JSLint没有像增量和减量运算符。将其替换为 i + = 1 或将 plusplus:true 指令添加到文件顶部(如果你'我不知道如何设置JSLint指令,这是一个例子。它们在文件顶部的普通注释中设置):

JSLint does not like the increment and decrement operators. Replace it with i += 1 or add the plusplus: true directive to the top of your file (if you're not sure how to set JSLint directives, here's an example. They are set in a normal comment at the top of your file):

/*jslint plusplus: true */

来自 JSLint文档


++ (增量)和 - (减量)运算符已知为
通过鼓励过多的欺骗行为导致错误代码。它们仅仅是因为能够导致病毒和其他
安全威胁的错误体系结构而只需

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.

完全荒谬的规则?你可以自己动手......

Completely ridiculous rule? You can make your own mind up...

这篇关于jslint中出现意外的'++'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆