2.Constructor方式 
 代码如下: 
function Car(){ 
this.color=”b”; 
this.length=1; 
this.run=function(){alert(”run”);} 
} 
var car1=new Car(); 
var car2=new Car(); 
 
这是最基本的方式,但是也存在和factory方式一样的毛病 
3.prototype方式 
 代码如下: 
function Car(){ 
} 
Car.prototype.color=”b”; 
Car.prototype.length=1; 
Car.prototype.run=function(){alert(”run”); 
} 
 
这个方式的缺点是,当这个类有一个引用属性时,改变一个对象的这个属性也会改变其他对象得属性 
比如: 
 代码如下: 
Car.prototype.data1=new Array(); 
var car1=new Car(); 
var car2=new Car(); 
car1.data1.push(”a”); 
 
此时,car2.data也就包含了”a”元素 
4.Prototype/Constructor杂合方式 [常用]
 代码如下: 
function Car(){ 
this.color=”b”; 
this.length=1; 
this.data1=new Array(); 
} 
Car.prototype.run=function(){ 
alert(”dddd”); 
} 
这种方式去除了那些缺点.是目前比较大范围使用的方式
5.动态prototype方式 [常用] 
 代码如下: 
function Car(){ 
this.color=”b”; 
this.length=1; 
this.data1=new Array(); 
if(typeof Car.initilize==”undefined”){ 
Car.prototype.run=function(){alert(”a”);} 
} 
Car.initilize=true; 
} 
 
这几种方式中,最常用的是杂合prototype/constructor 和 动态prototype方式