JavaScript Date prototype property
Example
Create a new Date object method:
Date.prototype.myMet=function()
{
if (this.getMonth()==0){this.myProp="January"};
if (this.getMonth()==1){this.myProp="February"};
if (this.getMonth()==2){this.myProp="March"};
if (this.getMonth()==3){this.myProp="April"};
if (this.getMonth()==4){this.myProp="May"};
if (this.getMonth()==5){this.myProp="June"};
if (this.getMonth()==6){this.myProp="July"};
if (this.getMonth()==7){this.myProp="August"};
if (this.getMonth()==8){this.myProp="Spetember"};
if (this.getMonth()==9){this.myProp="October"};
if (this.getMonth()==10){this.myProp="November"};
if (this.getMonth()==11){this.myProp="December"};
}
Create a Date object and call its myMet method:
var d = new Date();
d.myMet();
var monthname = d.myProp;
monthname Output result:
var d = new Date(); d.myMet(); document.write(d.myProp);
Try it »
Definition and Usage
The prototype property allows you to add properties and methods to an object.
When a prototype is constructed, all Date objects have properties and methods added by default.
Note: You can add properties and methods to a prototype, but you cannot assign a different prototype to an object. However, you can assign a new prototype to user-defined objects.
Note: Prototype is a global property applicable to nearly all JavaScript objects.
Browser support





All major browsers support the prototype property.
Syntax
Date.prototype.
name
=
value
JavaScript Date object