Date.prototype (Property)

The prototype for the Date object that can be used to extend the interface for all Date objects.

Availability:

ECMAScript edition - 2
JavaScript - 1.1
JScript - 3.0
Internet Explorer - 4.0
Netscape - 3.0
Netscape Enterprise Server - 2.0
Opera - 3.0
Property/method value type:Date object
JavaScript syntax:-Date.prototype
-myDate.constructor.prototype

The initial value of the prototype property refers to the built-in Date prototype object.

The value of the Date prototype object is NaN.

The example demonstrates how to provide extensions to all instances of this class by adding a function to the prototype object.

Example code:

   <HTML>
   <HEAD>
   </HEAD>
   <BODY>
   <SCRIPT>
   // Define a function that extends the output capabilities of Date objects
   function millennium()
   {
   return this.getFullYear()/1000;
   }
   // Register the new function
   Date.prototype.millennium = millennium;
   // Create a date and test the Date.millennium() method
   myDate = new Date();
   document.write(myDate.millennium())
   document.write("<BR>")
   </SCRIPT>
   </BODY>
   </HTML>

See also:prototype property

Property attributes:

ReadOnly, DontDelete, DontEnum.

Cross-references:

ECMA 262 edition 2 - section - 15.2.3.1

ECMA 262 edition 2 - section - 15.9.4.1

ECMA 262 edition 2 - section - 15.9.5

ECMA 262 edition 3 - section - 15.9.4.1