JavaScript ! Logical NOT Operator
The logical NOT operator (!) turns a truthy value into false and a falsy value into true. Using it twice (!!) converts any value to a boolean.
Description
The logical NOT operator ! returns false if its operand is truthy and true if it is falsy. Applying it twice, !!value, converts any value to its boolean equivalent, the same as Boolean(value).
The falsy values that ! turns into true are false, 0, -0, 0n, '', null, undefined and NaN; everything else, including empty arrays and objects, becomes false. So ![] is false, and checking for an empty array needs !arr.length.
It has a high precedence, so !a === b means (!a) === b, not !(a === b); use !== or parentheses to avoid this mistake. With in and instanceof, wrap the test in parentheses: !(key in obj).
Properties
- Operator
!- Category
- Logical
- Precedence
- 14 (1 is lowest, 18 is highest)
- Associativity
- right-to-left
Syntax
!xExample
Browser Support
The following information will show you the current browser support for the ! operator. Hover over a browser icon to see the version that first introduced support for this operator.
Desktop





Tablets & Mobile





