How much space does Number.POSITIVE_INFINITY
(aka Infinity
) or Number.NEGATIVE_INFINITY
take in memory for Javascript?
Asked
Active
Viewed 72 times
0
![](../../users/profiles/10179445.webp)
Hasan Sefa Ozalp
- 2,344
- 20
- 27
-
1The same as all values of type `number` (that aren’t optimized to integers): 8 bytes. – Sebastian Simon Jun 27 '20 at 16:28
-
See [Memory Usage Of Different Data Types in javascript](https://stackoverflow.com/q/4905861/4642212) and [What is the size (in memory) of a number?](https://stackoverflow.com/q/35652587/4642212). – Sebastian Simon Jun 27 '20 at 16:34
-
infinity fits into finite space. – Jonas Wilms Jun 27 '20 at 16:52
1 Answers
2
Infinity is a number, and all numbers are 64 bit IEEE 754 floating point values, so therefore Infinity is a 64 bit (8 byte) floating point. Realistically this is such a tiny amount that you shouldn't worry about it. Chances are if you're using it a lot, it's only getting assigned to one instance in memory anyway.
![](../../users/profiles/406249.webp)
Nick McCurdy
- 11,551
- 3
- 38
- 65