How to use Date Constructor in JavaScript

In this article I have described about Date Constructor property used in JavaScript.
  • 1742

Date Constructor property of JavaScript

  • As we know that the Date object is used to work with dates and times.
  • If we want to create the prototype of the Date object, we can use constructor property.

Browser support

Following are the main browsers which support the Constructor Property of array object

  • Internet Explorer.
  • Firefox.
  • Opera.
  • Google Chrome.
  • Safari.

Syntax

The syntax of prototype property of Date object as follows

Date.constructor

Lets take an example

<!DOCTYPE html>

<html>

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

<p id="MENU">Constructor Date object</p>

<button onclick="myFunction()">ON CLICK</button>

<script type="text/javascript">

    function myFunction() {

        var d = new Date();

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

        x.innerHTML = d.constructor;

    }

</script>

</body>

</html>

 

Output

 

 DATE CNSRCTR.jpg


When we click on Button


dt cnstrct.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.