JavaScript | BigInt.prototype.valueOf() Method

The BigInt.prototype.toString() method is an inbuilt method in JavaScript which is used to return the wrapped primitive value of a BigInt object.

Syntax:

bigIntObj.valueOf()

Parameters: This method does not accept any parameter.



Return value: This method returns a BigInt representing the primitive value of the specified BigInt object.

Below examples illustrate the BigInt.prototype.toString() method in JavaScript:

Example 1:

filter_none

edit
close

play_arrow

link
brightness_4
code

console.log(typeof Object(1324n));
console.log(typeof Object(24324).valueOf());

chevron_right


Output:

"object"
"number"

Example 2:

filter_none

edit
close

play_arrow

link
brightness_4
code

console.log(typeof Object("GeeksforGeeks"));
console.log(typeof Object("GeeksforGeeks").valueOf());

chevron_right


Output:

"object"
"string"

Supported Browsers: The browsers supported by BigInt.prototype.valueOf() method are listed below:

  • Google Chrome
  • Firefox
  • Opera
  • Edge

full-stack-img

My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.