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

OR (|) - 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

OR (|)

Baseline Widely available

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

**OR (|)** , 1 1 BigInt .

In this article

const a = 5; // 00000000000000000000000000000101
const b = 3; // 00000000000000000000000000000011

console.log(a | b); // 00000000000000000000000000000111
//  : 7

js
x | y

| BigInt . 32 , BigInt BigInt . , . BigInt BigInt OR , 32 OR . BigInt, TypeError .

2 (two's complement) . OR , .

OR .

x y x OR y
0 0 0
0 1 1
1 0 1
1 1 1
     9 (10) = 00000000000000000000000000001001 (2)
    14 (10) = 00000000000000000000000000001110 (2)
                 --------------------------------
14 | 9 (10) = 00000000000000000000000000001111 (2) = 15 (10)

32 . , 32 .

 : 11100110111110100000000000000110000000000001
 :             10100000000000000110000000000001

: | 0 . x | 0 x 32 , -2147483648 ~ 2147483647 . Math.trunc() .

BigInt . BigInt 0, BigInt 1 .

OR

js
// 9  (00000000000000000000000000001001)
// 14 (00000000000000000000000000001110)

14 | 9;
// 15 (00000000000000000000000000001111)

14n | 9n; // 15n

Specification
ECMAScript 2027 LanguageSpecification
# prod-BitwiseORExpression


Web Proxy Viewer  |  New URL  |  Original Page