JSHint 'nocomma' 选项有什么作用?
What does the JSHint 'nocomma' option do?
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 正在寻找什么场景。有人可以举个例子吗?
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"
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 正在寻找什么场景。有人可以举个例子吗?
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"