if statement with ! before variable

This question already has an answer here:

  • What does an exclamation mark before a variable mean in JavaScript 2 answers

  • ! is the plan language equivalent of 'not'. it is the shorthand way of saying if (boolval != true), notice the ! in != also means not as in not equal. So the section of code you posted pretty much just says if the timer is NOT active, activate it.


    The 0 is converted to false before ! logically negates it, producing true.


    if(x) means "if x is true "

    if(!x) means "if not x is true ", which is the same thing as "if x is false "

    链接地址: http://www.djcxy.com/p/13020.html

    上一篇: 按位操作布尔值

    下一篇: 如果声明与! 变量之前