JavaScript封装一个对象

xiaoxiao2025-05-28  33

function Car(sColor,iDoors,iMpg) { this.color = sColor; this.doors = iDoors; this.mpg = iMpg; this.drivers = new Array("Mike","John"); this.test=function(){ console.log("test"); } } Car.prototype.showColor = function() { alert(this.color); }; var objCar = new Car("red", 1, 2);

 

转载请注明原文地址: https://www.6miu.com/read-5030876.html

最新回复(0)