首页 文章

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

提问于
浏览
-1

在这个条件中使用not运算符( ! )给了我:

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

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

为什么不 ! 在这里工作?

1 回答

  • 7

    ! 应该在 () 之内:

    else if (!text.includes(input[j]))
    

相关问题