BigInt is javascript primitive data type. Number data type is not able to hold large or big numbers because of its limitation of 64-bit double-precision floating-point, hence BigInt data type is introduced in ECMAScript 2020 (ES11). with BigInt, large numbers can be used in javascript.

BigInt is not able to represent decimal or fractional part.

How to Create BigInt

In javascript, BigInt can be created in two ways.

  1. Appending n in integer value
  2. using BigInt() function

Appending n

<script>
let num = 1222223234232234n;
</script>

Add n at the last of value without any space, creates bigint number.

using BigInt()

<script>
let num = BigInt(1222223234232234234);
</script>

BigInt Operators

Same operators used with number data type variable can be used with BigInt variables.

<script>
let a  = 100n;
let b  = 44n;
let c = 0;
c =  a + b;
c =  a - b;
c =  a * b;
c =  a / b;
</script>

All arithmetic operations can be performed with BigInt numbers.