Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

prototype Property (Date)

Returns a reference to the prototype for a date.

date.prototype

The date argument is the name of an object.

Use the prototype property to provide a base set of functionality to a Date. New instances of an object "inherit" the behavior of the prototype assigned to that object.

For example, to add a method to the Date object that returns the value of the largest element of the array, declare the function, add it to Date.prototype, and then use it.

function max( ){
    var max = new Date();
    max.setFullYear(2200, 01, 01);
    return max;
}
Date.prototype.maxDate = max;
var myDate = new Date();

if (myDate < myDate.maxDate())
    document.write("today isn't the max");
else if (myDate == myDate.maxDate())
    document.write("today is the max"); 

// Output:
// today isn't the max

All intrinsic JavaScript objects have a prototype property that is read-only. Properties and methods may be added to the prototype, but the object may not be assigned a different prototype. However, user-defined objects may be assigned a new prototype.

Supported in the following document modes: Quirks, Internet Explorer 6 standards, Internet Explorer 7 standards, Internet Explorer 8 standards, Internet Explorer 9 standards, Internet Explorer 10 standards, Internet Explorer 11 standards. Also supported Store apps (Windows 8 and Windows Phone 8.1). See Version Information.

Show:
© 2015 Microsoft