JavaScript for Beginners

JavaScript BigInt

All JavaScript numbers are stored in a 64-bit floating-point format.

JavaScript BigInt is a new datatype (ES2020) that can be used to store integer values that are too big to be represented by a normal JavaScript Number.

 

Example :

 

<!DOCTYPE html>
<html>
<body>
<h1>JavScript Bigint</h1>
<p>A BigInt can not have decimals.</p>

<p id=”demo”></p>

<p>You cannot perform math between a BigInt type and a Number type.</p>

<script>
let x = BigInt(“123456789012345678901234567890”);
document.getElementById(“demo”).innerHTML = x;
</script>

</body>
</html>

 

Output

JavScript Bigint

A BigInt can not have decimals.

123456789012345678901234567890

You cannot perform math between a BigInt type and a Number type.

 

Description : 

JavaScript BigInt variables are used to store big integer values that are too big to be represented by a normal JavaScript Number. In JavaScript, numbers are usually stored using the Number data type, which can safely represent integers up to 2<sup>53</sup> – 1 (that’s 9007199254740991). 

BigInt is a special data type in JavaScript that allows you to work with very large integers,