写类方法
var oCar = new Object;
oCar.color = "blue";
oCar.drivers = new Array("Mike","John");
oCar.showColor = function() {
document.write(this.color);
document.write(this.drivers);
};
函数式的对象
function Car(sColor,iDoors,iMpg) {
this.color = sColor;
this.drivers = new Array("Mike","John");
}
Car.prototype.showColor = function() {
alert(this.color);
};
var oCar1 = new Car("red",4,23);