Skip to content
Related Articles
Get the best out of our app
GFG App
Open App
geeksforgeeks
Browser
Continue

Related Articles

JavaScript Date constructor Property

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

JavaScript Date constructor property returns the constructor function for an object. It is an ES1 feature and is supported by all browsers. The function which is returned by this property is just the reference to this function, not a date containing the function’s name. The JavaScript date constructor, string constructor, and boolean constructor return function Date() { [native code] }., function String() { [native code] } and function Boolean() { [native code] } respectively.

Syntax:  

Date.constructor

Return value: function Date() { [native code] }.

The below example illustrates the JavaScript Date constructor Property:

Example 1:

JavaScript




let date = new Date();
console.log("Date.constructor:" + date.constructor);


Output:

Date.constructor:function Date() { [native code] }

Example 2: This example uses the constructor property and returns the date constructor function.  

html




<!DOCTYPE html>
<html lang="en">
<head>
    <title>JavaScript Date constructor Property</title>
</head>
  
<body style="text-align:center;">
  
    <div>
        <h1 style="color: green;">GeeksforGeeks</h1>
        <p>
            JavaScript Date constructor Property
            returns the function that created the
            Date's prototype:
        </p>
        <b id="GFG"></b>
    </div>
  
    <!-- Script to use date constructor -->
    <script>
        let dy = new Date();
        document.getElementById("GFG").innerHTML
            = dy.constructor; 
    </script>
</body>
</html>


Output: 
 

Supported Browsers: The browsers supported by JavaScript Date constructor Property are listed below:  

  • Google Chrome 1 and above
  • Edge 12 and above
  • Firefox 1 and above
  • Internet Explorer 8 and above
  • Opera 3 and above
  • Safari 1 and above

We have a complete list of Javascript Date Objects, to check those please go through this Javascript Date Object Complete referencearticle.


My Personal Notes arrow_drop_up
Last Updated : 19 May, 2023
Like Article
Save Article
Similar Reads
Related Tutorials