gpt4 book ai didi

javascript - 三元语句的 JSLint 错误

转载 作者:行者123 更新时间:2023-11-30 11:52:10 24 4
gpt4 key购买 nike

我想知道为什么像这样的三元条件语句:

on_actu.boolean ? IMG1 = "on-actu.png": IMG1 = "off-actu.png";

给我以下 JSLint 错误:

expected an assignment or function call and instead saw an expression

最佳答案

你错误地使用了三元运算符。

ValueToAssign = BooleanConditional ? valueOne : valueTwo;

更多信息在这里:https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Conditional_Operator

关于javascript - 三元语句的 JSLint 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39131713/

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