How To Use Number Object ValueOf In JavaScript

In this article I am going to explain about Number Object ValueOf In JavaScript.
  • 1483

Use valueOf method in JavaScript

The valueOf() method returns the primitive number value in JavaScript.

All browsers support number object valueOf method.

Syntax

number.valueOf()

Example

<!DOCTYPE html>

<html>

<body style ="background-color:Red">

 

<p id="demo">Display the primitive value of a number.</p>

 

<button onclick="myFunction()">Click here</button>

 

<script type="text/javascript">

    function myFunction()

     {

        var num = 25;

        var x = document.getElementById("demo");

        x.innerHTML = num.valueOf();

    }

</script>

 

</body>

</html>

Output1

op1.jpg

Output2

 op2.jpg

Further Readings

You may also want to read these related articles :here

Ask Your Question 

Got a programming related question? You may want to post your question here

Programming Answers here

Categories

More Articles

© 2020 DotNetHeaven. All rights reserved.