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.
Share Improve this question edited Jun 9, 2021 at 16:39 Sebastian Simon 19.5k8 gold badges60 silver badges84 bronze badges asked Jan 29, 2020 at 23:31 Nikola DimNikola Dim 8469 silver badges21 bronze badges1 Answer
Reset to default 19From 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.