此页面由社区从英文翻译而来。了解更多并加入 MDN Web Docs 社区。

View in English Always switch to English

BigInt.prototype.valueOf()

基线 广泛可用

自 2020年9月 起,此特性已在主流浏览器中得到支持,可在大多数设备和浏览器版本中正常使用。

valueOf() 方法返回 BigInt 对象包装的原始值。

尝试一下

console.log(typeof Object(1n));
// Expected output: "object"

console.log(typeof Object(1n).valueOf());
// Expected output: "bigint"

语法

bigIntObj.valueOf()

返回值

表示指定 BigInt 对象的原始 BigInt 值。

示例

Using valueOf

js
typeof Object(1n); // object
typeof Object(1n).valueOf(); // bigint

规范

规范
ECMAScript® 2027 Language Specification
# sec-bigint.prototype.valueof

浏览器兼容性

请参阅