JavaScript propiedad Fecha prototipo
Ejemplos
Crear una nueva fecha de los métodos de objeto:
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"};
}
{
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"};
}
Crear un objeto Date, llame al método de objeto myMet:
var d = new Date();
d.myMet();
var monthname = d.myProp;
d.myMet();
var monthname = d.myProp;
monthname de salida:
var d = new Date();
d.myMet();
document.write(d.myProp);
Trate »
Definición y Uso
propiedad de prototipo le da la posibilidad de agregar propiedades y métodos a un objeto.
Cuando se construye un prototipo, todos los objetos de fecha se agregan de propiedades y métodos predeterminados.
Nota: Puede agregar propiedades y métodos para el prototipo, pero no se puede asignar un objeto prototipo diferente.Sin embargo, se puede asignar un nuevo prototipo de un objeto definido por el usuario.
Nota: El prototipo es una propiedad global, que casi la totalidad del objeto de JavaScript.
Soporte para el navegador
Todos los principales navegadores soportan propiedad de prototipo.
gramática
Date.prototype. name = value