Number valueOf() Method - Javascript Number

Javascript examples for Number:valueOf

Description

The valueOf() method returns the primitive value of a number.

Parameters

None

Return Value:

A Number, representing the primitive value of a number

The following code shows how to return the primitive value of a number:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<button onclick="myFunction()">Test</button>

<p id="demo"></p>

<script>
function myFunction() {//  w  w  w.  ja va  2s. co  m
    var num = 15;
    var n = num.valueOf()
    document.getElementById("demo").innerHTML = n;
}
</script>

</body>
</html>

Related Tutorials