javascript 對象創(chuàng)建
1 function WebFXTreeAbstractNode() {
2 alert(2);
3 this.books = "123456";
4 }
5
6 function person(firstname,lastname,age,eyecolor)
7 {
8 this.firstname=firstname
9 this.lastname=lastname
10 this.age=age
11 this.eyecolor=eyecolor
12 }
13 person.prototype = new WebFXTreeAbstractNode;
14 person.prototype.toString = function(){
15 return this.firstname + " 的年齡是 " + this.age + " 歲。" + this.books+" is books ";
16 }
17
18 var myFather=new person("John","Adams",35,"black");
19
20 document.write(myFather);
21
2 alert(2);
3 this.books = "123456";
4 }
5
6 function person(firstname,lastname,age,eyecolor)
7 {
8 this.firstname=firstname
9 this.lastname=lastname
10 this.age=age
11 this.eyecolor=eyecolor
12 }
13 person.prototype = new WebFXTreeAbstractNode;
14 person.prototype.toString = function(){
15 return this.firstname + " 的年齡是 " + this.age + " 歲。" + this.books+" is books ";
16 }
17
18 var myFather=new person("John","Adams",35,"black");
19
20 document.write(myFather);
21
posted on 2009-07-08 13:53 星期五 閱讀(129) 評論(0) 編輯 收藏 所屬分類: web 2.0