错误:左手标志分配无效(II)

时间:2019-08-06 23:42:44

标签: javascript

此条件运算符给出了左手赋值错误,我似乎无法弄清原因。

else if (schedule == undefined && season != "winter" && typeb = false) {
  console.log("It works");
}

2 个答案:

答案 0 :(得分:1)

一个等号是赋值。您需要typeb == falsetypeb === false

else if (schedule == undefined && season != "winter" && typeb == false) {
console.log("It works")
  }

答案 1 :(得分:0)

您在条件中使用=(赋值运算符)-将其更改为==(比较运算符):

else if (schedule == undefined && season != "winter" && typeb == false) {...}

或仅使用!

else if (schedule == undefined && season != "winter" && !typeb) {...}