gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-30 12:05:02 25 4
gpt4 key购买 nike

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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com