最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

What does character 'n' after numeric literal mean in JavaScript? - Stack Overflow

programmeradmin4浏览0评论

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 badges
Add a comment  | 

1 Answer 1

Reset to default 19

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.

发布评论

评论列表(0)

  1. 暂无评论