In JavaScript, all integer variables are signed integers by default. What does this mean?
Signed integers use 31 bits to represent the value of the integer, and bit 32 to represent the sign of the integer, with 0 representing a positive number and 1 representing a negative number.
The value range is from -2^31 - 2^31-1 which is -2147483648 to 2147483647.
When JavaScript performs bit operations, it uses a 32-bit signed integer type, which means that the result of the conversion is also a 32-bit signed integer type. Sometimes, unexpected results will occur when we perform shifting. The following is a comparison between C language and JS.
C language