中文字幕一区二区人妻电影,亚洲av无码一区二区乱子伦as ,亚洲精品无码永久在线观看,亚洲成aⅴ人片久青草影院按摩,亚洲黑人巨大videos

JavaScript Date prototype 屬性

Date 對象參考手冊 JavaScript Date 對象

實(shí)例

創(chuàng)建一個(gè)新的日期對象方法:

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"};
}

創(chuàng)建一個(gè) Date 對象,調(diào)用對象的 myMet 方法:

var d = new Date();
d.myMet();
var monthname = d.myProp;

monthname 輸出結(jié)果:

var d = new Date(); d.myMet(); document.write(d.myProp);

運(yùn)行代碼 ?

定義和用法

prototype 屬性使您有能力向?qū)ο筇砑訉傩院头椒ā?/p>

當(dāng)構(gòu)造一個(gè)原型,所有的日期對象都會(huì)默認(rèn)添加屬性和方法。

注意: 可將屬性和方法添加到原型中,但不能為對象分配其他原型。 但是,可以向用戶定義的對象分配新的原型。

注意: Prototype是一個(gè)全局屬性,這對于幾乎全部的JavaScript對象。


瀏覽器支持

Internet ExplorerFirefoxOperaGoogle ChromeSafari

所有主要瀏覽器都支持prototype 屬性。


語法

Date.prototype.name=value

Date 對象參考手冊 JavaScript Date 對象

其他擴(kuò)展