In JavaScript, integers have 8 bytes; the number memory space ratio does not distinguish between specific types. The basic variable type uses eight bytes of memory. Numbers and integers are stored in the form of 64-bit floating point numbers. , which is 8 bytes.
The operating environment of this tutorial: Windows 10 system, JavaScript version 1.8.5, Dell G3 computer.
Let’s talk about the number type first
“The JavaScript number type uses 64-bit floating point numbers defined by the IEEE754 standard to represent numbers”————Excerpted from Rhinoceros Book
The picture below is the explanation in mdn
Note: The memory space ratio of number does not distinguish between specific types (Java does). Integer types (byte, short, int, long) and floating point types (float, double)
If we only focus on numbers, the memory in the computer is 8Byte, that is, 8 bytes.
1byte (byte) = 8bit (bit)
8byte = 64 bits
Extended other data types
JavaScript basic data types occupy the largest share of the computer The memory is 8 bytes
Basic data types: string, number, undefined, boolean, null
Generally, Chinese occupies 2 bytes and English occupies 1 byte.
Related recommendations: javascript learning tutorial
The above is the detailed content of How many bytes are integers in JavaScript?. For more information, please follow other related articles on the PHP Chinese website!