Javascript中的运算符不会出现意外的令牌错误

时间:2015-07-16 22:23:47

标签: javascript if-statement logical-operators not-operator

在此条件中使用not运算符(!)会给我:

  

“未捕获的SyntaxError:意外的令牌!”

if (text.includes(input[j])) {
   $(Messages[i]).hide();
}
else if !(text.includes(input[j])) {
   $(Messages[i]).show();
}

为什么!不在这里工作?

1 个答案:

答案 0 :(得分:7)

()应在else if (!text.includes(input[j])) 之内:

{{1}}