[ Web Proxy ]
URL:
Viewing: https://developer.mozilla.org/ru/docs/Web/JavaScript/Reference/Operators/Logical_NOT [Back]  [Original]

(!) - JavaScript | MDN

This page was translated from English by the community. Learn more and join the MDN Web Docs community.

View in English Always switch to English

(!)

Baseline
Widely available

This feature is well established and works across many devices and browser versions. Its been available across browsers since 2015 ..

(!) ( ) . () . , true, false; true.

In this article

const a = 3;
const b = -2;

console.log(!(a > 0 || b > 0));
// Expected output: false

js
!expr;

false, true; true.

true, (truthy). false, (falsy).

, false:

  • null;
  • NaN;
  • 0;
  • ("", '', ``);
  • undefined.

, ! , Boolean, , . ( ) , Boolean.

! ( ).

js
n1 = !true; // !t  false
n2 = !false; // !f  true
n3 = !""; // !f  true
n4 = !"Cat"; // !t  false

(!!)

, . "" "" (. truthy falsy)).

Boolean.

js
n1 = !!true; // !!truthy  true
n2 = !!{}; // !!truthy  true:   - ...
n3 = !!new Boolean(false); // ... Boolean-   false   .valueOf()!
n4 = !!false; // !!falsy  false
n5 = !!""; // !!falsy  false
n6 = !!Boolean(false); // !!falsy  false

:

js
!!bCondition;

:

js
bCondition;

Specification
ECMAScript 2027 LanguageSpecification
# sec-logical-not-operator


Web Proxy Viewer  |  New URL  |  Original Page