亚洲区国产区激情区无码区,国产成人mv视频在线观看,国产A毛片AAAAAA,亚洲精品国产首次亮相在线

JavaScript Date prototype 屬性

 JavaScript Date 對(duì)象

prototype屬性可以將屬性和方法添加到您的Date()對(duì)象。

注意:prototype是一個(gè)全局屬性,幾乎所有對(duì)象(數(shù)字,數(shù)組,字符串和日期等)都可用。

語法:

Date.prototype.name = value

創(chuàng)建一個(gè)新的date方法,將month-numeric值轉(zhuǎn)換為month-name值:

Date.prototype.showMonth = function() {
var arr = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];
return arr[this.getMonth()];
};

然后創(chuàng)建一個(gè)日期,并調(diào)用showMonth()方法:

var d = new Date();
var month = d.showMonth();// calling new method

測(cè)試看看?/?

瀏覽器兼容性

所有瀏覽器完全支持prototype屬性:

屬性
prototype

 JavaScript Date 對(duì)象