Favorites

JavaScript ! Logical NOT Operator

☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee
!
JavaScript Logical OperatorThis operator is supported by all modern browsers.
Updated 28th November 2026

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

!x

Example

console.log(!true, !0, !'');
console.log(!!'text', !!null);
const list = [];
if (!list.length) console.log('List is empty');

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.

This operator is supported by all modern browsers.

Desktop

Chrome
Edge
Firefox
Opera
Safari

Tablets & Mobile

Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-
Supported Unknown Not supported
☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee