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

NOT (~) - 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

NOT (~)

Baseline Widely available

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

NOT (~) . 32 .

In this article

const a = 5; // 00000000000000000000000000000101
const b = -3; // 11111111111111111111111111111101

console.log(~a); // 11111111111111111111111111111010
// Expected output: -6

console.log(~b); // 00000000000000000000000000000010
// Expected output: 2

~a

32 (0 1) . 32 . 32 32 .

Before: 11100110111110100000000000000110000000000001
After:              10100000000000000110000000000001

.

NOT .

a NOT a
0 1
1 0
js
 9 (base 10) = 00000000000000000000000000001001 (base 2)
               --------------------------------
~9 (base 10) = 11111111111111111111111111110110 (base 2) = -10 (base 10)

32 2 . , .

x NOT -(x + 1) . ~-5 4 .

32 ~-1 ~4294967295 (232 - 1) 0 .

NOT

js
~0; // -1
~-1; // 0
~1; // -2

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


Web Proxy Viewer  |  New URL  |  Original Page