<script type="text/javascript">
//使用构造函数定义非函数属性
function Car(scolor,sdoors,smpg)
{
this.color=scolor;
this.doors=sdoors;
this.mpg=smpg;
this.drivers=new Array("mat","sue");
}
//使用原型定义函数属性
Car.prototype.showColor=function (){
alert(this.color);
}
var oCar1=new Car("red",1,23);
var oCar2=new Car("blue",2,32);
oCar1.drivers.push("apple");
alert(oCar1.drivers);
alert(oCar2.drivers);
alert(oCar1.color);
alert(oCar2.color);
alert(oCar1 instanceof Car);
</script>
使用构造函数定义非函数属性,使用原型定义函数属性,定义类