JavaScript BigInt valueOf() Method

The BigInt.toString() method is an inbuilt method in JavaScript that 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.

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

Example 1: This example shows the basic use of the BigInt.prototype.toString() method in JavaScript.

javascript




<script>
    console.log(typeof Object(1324n));
    console.log(typeof Object(24324).valueOf());
</script>


Output:

"object"
"number"

Example 2: This example shows the basic use of the BigInt.prototype.toString() method in JavaScript.

javascript




<script>
    console.log(typeof Object("zambiatek"));
    console.log(typeof Object("zambiatek").valueOf());
</script>


Output:

"object"
"string"

We have a complete list of Javascript BigInt Methods, to check those please go through the Javascript BigInt Complete Reference article.

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

  • Google Chrome 67 and above
  • Edge 79 and above
  • Firefox 68 and above
  • Opera 54 and above
  • Safari 14 and above
Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, zambiatek Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button