What are integers in JavaScript?
According to the ECMAScript specification, all numbers in JavaScript are floatingpoint. Yet, the notion of
integer comes up occasionally. This blog post explains what it means.
What are integers?
JavaScript has only floatingpoint numbers. Integers appear internally in two ways. First, most JavaScript engines store a small enough number without a decimal fraction as an integer (with, for example, 31 bits) and maintain that representation as long as possible. They have to switch back to a floating point representation if a number’s magnitude grows too large or if a decimal fraction appears.
Second, the ECMAScript specification has integer operators: namely, all of the bitwise operators. Those operators convert their operands to 32bit integers and return 32bit integers. For the specification, integer only means that the numbers don’t have a decimal fraction, and 32bit means that they are within a certain range. For engines, 32bit integer means that an actual integer (nonfloatingpoint) representation can usually be introduced or maintained.
Ranges of integers
Internally, the following ranges of integers are important in JavaScript:

Safe integers [1], the largest practically usable range of integers that JavaScript supports:
 53 bits plus a sign, range (−2^{53}, 2^{53})
 Array indices [2]:
 32 bits, unsigned
 Maximum length: 2^{32}−1
 Range of indices: [0, 2^{32}−1) (excluding the maximum length!)

Bitwise operands [3]:
 Unsigned right shift operator (>>>): 32 bits, unsigned, range [0, 2^{32})
 All other bitwise operators: 32 bits, including a sign, range [−2^{31}, 2^{31})

“Char codes”, UTF16 code units as numbers:
 Accepted by String.fromCharCode()
 Returned by String.prototype.charCodeAt()
 16 bit, unsigned
More blog posts on integers
All blog posts on integers have the label
jsint. Converting to integer is covered by two blog posts:
References
 Safe integers in JavaScript
 Arrays in JavaScript
 Label bitwise_ops: blog posts on bitwise operators