I've seen
const num = 123456789000000000000n;
And don't know what the n at the end of numeric literal does?
At the time of writing, when searching online for "What does character 'n' after numeric literal mean in JavaScript" nothing comes up.
I've seen
const num = 123456789000000000000n;
And don't know what the n at the end of numeric literal does?
At the time of writing, when searching online for "What does character 'n' after numeric literal mean in JavaScript" nothing comes up.
From BigInt on MDN:
A BigInt is created by appending n to the end of an integer literal — 10n — or by calling the function BigInt().
In essence, BigInt
allows for storing large integers, as otherwise a large numeric literal would be converted into a floating point and lose precision of the least significant digits.