BigInt.prototype.valueOf()

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since September 2020.

Phương thức valueOf() của các giá trị BigInt trả về giá trị nguyên thủy được bao bọc của một đối tượng BigInt.

Try it

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

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

Cú pháp

js
valueOf()

Tham số

Không có.

Giá trị trả về

Một BigInt đại diện cho giá trị nguyên thủy của đối tượng BigInt đã chỉ định.

Ví dụ

Sử dụng valueOf

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

Đặc tả

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

Tương thích trình duyệt

Xem thêm