If you have studied strongly typed languages, then you should understand that a certain value must be stored in memory with a pre-allocated number of bytes for it. For example, int
4 bytes are allocated for a number , which is equal to 32 bits and can contain 2³² values, which means we can express in the decimal system from -2 147 483 647 to 2 147 483 647. What type of number is used in JS?
The EcmaScript standard says that Number Value: primitive value corresponding to a double-precision 64-bit binary format IEEE 754 value. That is, a number double
(double precision number) occupying 8 bytes = 64 bits (of which 1 bit is allocated to indicate the sign of the number, 11 bits for the order and 52 is the mantissa, everything after the decimal point).
Value range: 1.7E +/- 308 (15 digits). You can check and see this number in full by printing the maximum allowed number of the Number object in the console. Number.MAX_VALUE
Here is a link to the IEEE754 standard: https://en.wikipedia.org/wiki/IEEE_754 If you go beyond this number, then Number will give us a value Infinity
...
, double
?
: 9,007,199,254,740,991 ~9 . , . Number: Number.MAX_SAFE_INTEGER
.
, , :
, isSafeInteger()
:
, , double
. , ? , , , int
4 , 8! , V8 Number:
, . int
int32
Uint32
( ±), BigInt
. Integer
Number
, Int32
Uint32
Integer
.
gitHub': https://github.com/v8/v8/blob/master/include/v8.h#L3039
V8 C++ 4 . , V8 double 8 . , , .
Performance Tip for JS in v8 Chris Wilsonhttps://www.html5rocks.com/en/tutorials/speed/v8/
. JS — , API . , window.setTimeout()
. JavaScript. setTimeout int32
, , 2 147 483 647, 9 . setTimout()
2 147 483 648 ( 1 Int32
), . JS . .
P.S. , setTimeout 25 . , .
Thank you all, subscribe to my VK page and join our group of fans of frontend development