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

(<<) - JavaScript | MDN

MDN Web Docs

View in English Always switch to English

(<<)

Baseline

20157

(<<) 1 0

const a = 5; // 00000000000000000000000000000101
const b = 2; // 00000000000000000000000000000010

console.log(a << b); // 00000000000000000000000000010100
// : 20

js
x << y

<< 2 32 32 TypeError

2 9 << 2 36

     9 (10 ): 00000000000000000000000000001001 (2 )
                  --------------------------------
9 << 2 (10 ): 00000000000000000000000000100100 (2 ) = 36 (10 )

x y x * 2 ** y 9 << 3 9 * (2 ** 3) = 9 * (8) = 72

32 32 32

Before: 11100110111110100000000000000110000000000001
After:              10100000000000000110000000000001

32 32 0 31 100 << 32 100 << 0 (100) 32 32 0

: << 0 x 0 x 32 -2147483648 2147483647 Math.trunc()

0 1

js
9 << 3; // 72

// 9 * (2 ** 3) = 9 * (8) = 72

9n << 3n; // 72n

ECMAScript 2027 LanguageSpecification
# sec-left-shift-operator


Web Proxy Viewer  |  New URL  |  Original Page