Javascript bitwise left-shift operator use Introduction (<<) _ Basics

Source: Internet
Author: User
Tags bitwise

Bitwise left-shift operator (<<)
The bit of the left-shift expression.

result = expression1 << expression2


Any variable.


Any expression.


Any expression.

The << operator shifts all bits of the expression1 to the left expression2 the specified number of digits. For example:

var temp
temp = << 2
The value of the variable temp is 56 because 14 (that is, binary 00001110) shifts to the left two digits equals 56 (that is, binary 00111000).

The Javascript bitwise Left operator (<<) converts an expression number to binary, and then shifts the bits of the expression to the left.

result = "number to be shifted" << "number of displacement digits"

The bitwise Left operator (<<) shifts the bits of the "digits to be shifted" to the left by the number of digits specified in the offset digits. For example:

Copy Code code as follows:

var temp;
temp = << 2;
14 of the binary is 00111000
00001110 left shift 2 bit 00111000 = 56
Alert (temp);
Pop-up "56"

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.