[英]What does the JSHint 'nocomma' option do?
The 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.
如果误用,逗号运算符可能会隐藏语句的值并促使错误的代码。
But it's still not clear to me what scenario JSHint is looking for. 但是我仍然不清楚JSHint正在寻找什么样的场景。 Could somebody please provide an example?
有人可以提供一个例子吗?
The comma operator evaluates each of its operands (from left to right) and returns the value of the last operand.
逗号运算符计算其每个操作数(从左到右)并返回最后一个操作数的值。
Example 例
function myFunc() {
var message = "hello";
return (message += "howareya", message);
}
// returns "hellohowareya"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.