W3School TIY
(请在下面的文本框中编辑您的代码,然后单击此按钮测试结果。)
编辑您的代码:
<html> <body> <script type="text/javascript"> function Car(sColor,iDoors,iMpg) { this.color = sColor; this.doors = iDoors; this.mpg = iMpg; this.showColor = function() { document.write(this.color); }; } var oCar1 = new Car("red",4,23); var oCar2 = new Car("blue",3,25); oCar1.showColor(); document.write("<br />") oCar2.showColor(); </script> </body> </html>
查看结果: