W3School TIY Editor
W3School 在线教程
改变方向
暗黑模式
运行代码
<html> <body> <script type="text/javascript"> function Car(sColor,iDoors,iMpg) { this.color = sColor; this.doors = iDoors; this.mpg = iMpg; this.drivers = new Array("Mike","John"); } Car.prototype.showColor = function() { document.write(this.color); }; var oCar1 = new Car("red",4,23); var oCar2 = new Car("blue",3,25); oCar1.drivers.push("Bill"); document.write(oCar1.drivers); document.write("<br />") document.write(oCar2.drivers); </script> </body> </html>