DEV Community

Avinashd
Avinashd

Posted on

Js in bits - 5.2(datatypes - BigInt)

Learning js should be fun. It is fun if it's easy.
I tried my best in writing this, to understand it the easy way.

datatypes

BigInt

There are very large numbers like 9007199254740995(2^53) and Js can't store them using Number data type.

Image description

If we do the following calculation, Js stores the approx value.
Below, 1 is added & Js can't store the result with Number datatype.

Image description

Solution: BigInt

Adding n to the end of the number tells Js that it is a BigInt datatype. Js can successfully store the very large number.

Image description

Leave y'r thoughts....

Top comments (0)