javascript - JSHint 'nocomma' 选项有什么作用?

标签 javascript jshint

documentation says :

This option prohibits the use of the comma operator. When misused, the comma operator can obscure the value of a statement and promote incorrect code.

但我仍然不清楚 JSHint 正在寻找什么场景。有人可以举个例子吗?

最佳答案

MDN: Comma Operator

The comma operator evaluates each of its operands (from left to right) and returns the value of the last operand.

示例

function myFunc() {
  var message = "hello";

  return (message += "howareya", message);
}
// returns "hellohowareya"

关于javascript - JSHint 'nocomma' 选项有什么作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35485621/

相关文章:

javascript - 我的代码中出现循环复杂度错误

javascript - 单击复选框+按钮后动态更改 slider 值

javascript - JSHint 返回奇怪的错误

javascript - InnerHTML 更新不起作用

javascript - ExtJS 无法正确渲染组件

javascript - CSSLint : How to save log from console log into file

javascript - 如何重写此 Javascript 代码以避免 JSHint 警告?

javascript - 如何让 JSHint 提示缺少函数参数?

java - 比较两个音频文件。声音匹配

javascript - CSS-将页脚粘贴到页面底部(因此仅在滚动后可见)没有 html 选择器?