!(NOT) Operator

!(NOT) Operator reverses the boolean result of the operand (or condition). It first converts the operand to a boolean type and then returns its flipped value.

Example: In this example, we will perform the NOT operation on number multiple times.

Javascript
// !(NOT) operator
let i = 0;
console.log((!i));
console.log(!!i);

Output:

true
false

Explanation: Since zero is treated as a falsy value therefore NOT operation on zero will return true and when this operation is performed again we get true as output.

JavaScript Logical Operators

Similar Reads

Logical operators

The logical operators are mostly used to make decisions based on conditions specified for the statements. It can also be used to manipulate a boolean or set termination conditions for loops. It allows us to compare variables or values....

!(NOT) Operator

!(NOT) Operator reverses the boolean result of the operand (or condition). It first converts the operand to a boolean type and then returns its flipped value....

&&(AND) Operator

The && operator accepts multiple arguments and evaluates the operator from left to right. It returns true only if all the operands that are evaluated are true...

||(OR) Operator

The OR operator is somewhat opposite of the ‘AND’ operator. It also evaluates the operator from left to right and returns true even if one operand is evaluated as true...

Contact Us