JavaScript Lint inc_dec_within_stmt 警告
发出警告的原因/重要性?
inc_dec_within_stmt - increment (++) and decrement (--) operators used as part of greater statement
这样的代码行时
someValue = count++;
有人可以解释为什么 javascriptlint (不是 jslint)在遇到诸如“为什么我应该保持此检查打开?”
Can someone explain the reason/importance of why javascriptlint (not jslint) gives the warning
inc_dec_within_stmt - increment (++) and decrement (--) operators used as part of greater statement
when it comes across a line of code like
someValue = count++;
Why should I keep this check turned on?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是一个警告,因为这样的声明对于人类读者来说可能会产生歧义。
虽然你和我可以看到它并理解它相当于
经验不足的程序员可能会错误地将其解释为
当然,这是最简单的例子。 在这样的行中更值得发出警告:)
尽管我不能说我在生产代码中见过这样的行,但
It's a warning because a statement like that can be ambiguous to human readers.
While you and I can look at that and understand that it is equivalent to
a less experienced programmer might incorrectly interpret that as
Of course, this is the simplest example. The warning is much more deserved in a line like
although I can't say I've ever seen a line like that in production code :)