1 <SCRIPT type = "text/JavaScript">
2 // factory Model
3 function person (name, age, add ){
4 var o = new object ();
5 O. Name = Name;
6 O. Age = age;
7 O. Add = add;
8 o. smay = function (){
9 alert (O. Name );
10}
11 return O;
12}
13 var person1 = person ('xioawang ', 25, 'beijing ');
14 person1.smay ();
15 </SCRIPT>
1 <SCRIPT type = "text/JavaScript">
2 // Constructor
3 function person (name1, age1, Add1 ){
4 This. name1 = name1;
5 This. age1 = age1;
6 This. Add1 = Add1;
7 This. smay1 = function (){
8 alert (this. name1 );
9}
10}
11 var person2 = new person ('xiaoli', 25, 'handand ');
12 person2.smay1 ();
13 </SCRIPT>
1 <SCRIPT type = "text/JavaScript">
2 // prototype
3 function person11 (name2, age2, Add2 ){
4 person11.prototype. name2 = 'xiaozhang ';
5 person11.prototype. age2 = 15;
6 person11.prototype. Add2 = 'hebei ';
7 person11.prototype. saym2 = function (){
8 alert (person11.prototype. name2 );
9}
10}
11 var person22 = new person11 ();
12 person22.saym2 ();
13 var person33 = new person11 ();
14 person33.saym2 ();
15 alert (person11.prototype. isprototypeof (person22 ));
16 </SCRIPT>
1 <SCRIPT type = "text/JavaScript">
2 // simpler Prototype Method
3 function person111 (){
4}
5 person111.prototype = {
6 name222: 'xiaowang ',
7 age222: 25,
8 add222: 'beijing ',
9 smay222: function (){
10 alert (this. name222 );
11}
12}
13 var person333 = new person111;
14 person333.smay222 ();
15 </SCRIPT>