JavaScript NOT
JavaScript NOT Operator is used to invert the value of a boolean condition.
NOT Operator Symbol
The symbol used for NOT Operator is !
.
ADVERTISEMENT
Syntax
The syntax to use NOT Operator with an operand a
is
!a
a
can be a Boolean variable, or boolean expression, or a complex condition.
NOT Truth Table
The following truth table provides the output of NOT operator for different values of operands.
a | !a |
---|---|
true | false |
false | true |
NOT Operator negates the given value.
Examples
In the following example, we take a boolean variable with different values: true and false, and find their logical NOT output.
index.html
In the following example, we will use NOT operator for a boolean condition in If Statement.
index.html
Conclusion
In this JavaScript Tutorial, we learned about Logical NOT Operator, its syntax, and usage with examples.