对象本田CRV
<script> window.onload = function (ev) { var vcar = new Car("本田", "CRV", 45, 2); vcar.startup(); vcar.Startengine(); vcar.changeSpeed(); vcar.swerve(); vcar.stop(); vcar.Turnofftheengine(); } function Car(make, model, currentSpeed, displacement) { var currentSpeed = currentSpeed; this.startup = function () { document.write("启动:0") } this.Startengine= function () { var speed = currentSpeed; document.write("<br>"+"启动引擎:"+speed) } this.changeSpeed = function () { var speed = currentSpeed+20; document.write("<br>"+"加速:"+speed) } this.swerve = function () { var speed = currentSpeed-20; document.write("<br>"+"转向:"+speed) } this.stop = function () { var speed = 0; document.write("<br>"+"刹车:"+speed) } this.Turnofftheengine = function () { var speed = currentSpeed-25; document.write("<br>"+"关引擎:"+speed) } } </script>