Logical NOT (!)
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
Thelogical NOT (!) (logical complement, negation) operator takes truth tofalsity and vice versa. It is typically used with boolean (logical)values. When used with non-Boolean values, it returnsfalse if its singleoperand can be converted totrue; otherwise, returnstrue.
In this article
Try it
const a = 3;const b = -2;console.log(!(a > 0 || b > 0));// Expected output: falseSyntax
!xDescription
Returnsfalse if its single operand can be converted totrue;otherwise, returnstrue.
If a value can be converted totrue, the value is so-calledtruthy. If a value can be converted tofalse, the value isso-calledfalsy.
Examples of expressions that can be converted to false are:
null;NaN;0;- empty string (
""or''or``); undefined.
Even though the! operator can be used with operands that are not Boolean values, it can still be considered a boolean operator since its return value can always be converted to aboolean primitive. To explicitly convert its return value (or any expression in general) to the corresponding boolean value, use a double NOT operator (!!) or theBoolean constructor.
Examples
>Using NOT
The following code shows examples of the! (logical NOT) operator.
!true; // !t returns false!false; // !f returns true!""; // !f returns true!"Cat"; // !t returns falseDouble NOT (!!)
It is possible to use a couple of NOT operators in series to explicitly force theconversion of any value to the correspondingboolean primitive.The conversion is based on the "truthiness" or "falsiness" of the value (seetruthy andfalsy).
The same conversion can be done through theBoolean() function.
!!true; // !!truthy returns true!!{}; // !!truthy returns true: any object is truthy…!!new Boolean(false); // … even Boolean objects with a false .valueOf()!!!false; // !!falsy returns false!!""; // !!falsy returns false!!Boolean(false); // !!falsy returns falseConverting between NOTs
The following operation involvingbooleans:
!!bConditionis always equal to:
bConditionSpecifications
| Specification |
|---|
| ECMAScript® 2026 Language Specification> # sec-logical-not-operator> |