How to use ValueOf in Javascript

In this article I am going to explain about ValueOf() method in JavaScript.
  • 1207

JavaScript ValueOf() Method

JavaScript ValueOf() method use for find primitive value of Date object. When its function execute primitive value will return in the form of millisecond since 1 January 1970.

Syntax

Date.ValueOf()

Example

<html>

<head>

    <script type="text/javascript">

        function myfun() {

            var dd = new Date();

            var mm = document.getElementById("tst");

            mm.innerHTML = dd.valueOf();

        }

    </script>

</head>

<body>

    <p>

        click button to show primitive value</p>

    <h3 id="tst" style="color: red">

    </h3>

    <button onclick="myfun()">

        click me</button>

</body>

</html>

 

Output

 

 ValueOf.jpg

 

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
 

Categories

More Articles

© 2013 dotNetheaven. All rights reserved.