File size: 1,022 Bytes
780c9fe |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
---
title: BigInt.prototype.valueOf()
short-title: valueOf()
slug: Web/JavaScript/Reference/Global_Objects/BigInt/valueOf
page-type: javascript-instance-method
browser-compat: javascript.builtins.BigInt.valueOf
sidebar: jsref
---
The **`valueOf()`** method of {{jsxref("BigInt")}} values returns the wrapped primitive value
of a {{jsxref("BigInt")}} object.
{{InteractiveExample("JavaScript Demo: BigInt.prototype.valueOf()", "shorter")}}
```js interactive-example
console.log(typeof Object(1n));
// Expected output: "object"
console.log(typeof Object(1n).valueOf());
// Expected output: "bigint"
```
## Syntax
```js-nolint
valueOf()
```
### Parameters
None.
### Return value
A BigInt representing the primitive value of the specified {{jsxref("BigInt")}} object.
## Examples
### Using `valueOf`
```js
typeof Object(1n); // object
typeof Object(1n).valueOf(); // bigint
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- {{jsxref("BigInt.prototype.toString()")}}
|