JavaScript 中数字文字后的字符 'n' 是什么意思?
What does character 'n' after numeric literal mean in JavaScript?
我看过
const num = 123456789000000000000n;
不知道数字文字末尾的 n 有什么作用?
在撰写本文时,在线搜索 "What does character 'n' after numeric literal mean in JavaScript" 时没有任何结果。
来自 MDN (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt)
A BigInt is created by appending n to the end of an integer literal —
10n — or by calling the function BigInt().
本质上,BigInt 允许存储大整数,否则大数字文字将被转换为浮点数并失去最低有效数字的精度。
我看过
const num = 123456789000000000000n;
不知道数字文字末尾的 n 有什么作用?
在撰写本文时,在线搜索 "What does character 'n' after numeric literal mean in JavaScript" 时没有任何结果。
来自 MDN (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt)
A BigInt is created by appending n to the end of an integer literal — 10n — or by calling the function BigInt().
本质上,BigInt 允许存储大整数,否则大数字文字将被转换为浮点数并失去最低有效数字的精度。