×
参考手册概览

JavaScript 对象

JavaScript Array 对象手册 JavaScript Array 对象JavaScript Boolean 对象JavaScript Date 对象JavaScript Math 对象JavaScript Number 对象JavaScript String 对象JavaScript RegExp 对象JavaScript 全局属性/函数JavaScript 运算符

Browser 对象

Window 对象Navigator 对象Screen 对象History 对象Location 对象

DOM 对象

HTML DOM DocumentHTML DOM 元素对象HTML DOM 属性对象HTML DOM 事件对象

HTML 对象

<a><area><audio><base><blockquote><body><button><canvas><col><colgroup><datalist><del><details><dialog><embed><fieldset><form><iframe><frameset ><img><ins><input> - button<input> - checkbox<input> - color<input> - date<input> - datetime<input> - datetime-local<input> - email<input> - file<input> - hidden<input> - image<input> - month<input> - number<input> - range<input> - password<input> - radio<input> - reset<input> - search<input> - submit<input> - text<input> - time<input> - url<input> - week<keygen><link><label><legend><li><map><menu><menuItem><meta><meter><object><ol><optgroup><option><param><progress><q><script><select><source><style><table><td><th><tr><textarea><title><time><track><video>

JavaScript Date prototype 属性


JavaScript Date 对象JavaScript Date 对象


实例

创建一个新的日期对象方法:

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

创建一个 Date 对象,调用对象的 myMet 方法:

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

monthname 输出结果:

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

尝试一下 »

定义和用法

prototype 属性使您有能力向对象添加属性和方法。

当构造一个原型,所有的日期对象都会默认添加属性和方法。

注意: 可将属性和方法添加到原型中,但不能为对象分配其他原型。 但是,可以向用户定义的对象分配新的原型。

注意: Prototype是一个全局属性,这对于几乎全部的JavaScript对象。


浏览器支持

Internet ExplorerFirefoxOperaGoogle ChromeSafari

所有主要浏览器都支持prototype 属性。


语法

Date.prototype.name=value

JavaScript Date 对象JavaScript Date 对象


分类导航

关注微信下载离线手册

bootwiki移动版 bootwiki
(群号:472910771)