2019-12-02
17:14:30
<!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>Car properties</title> <script> var fiat = { make: "Fiat", model: "500", year: 1957, color: "Medium Blue", passengers: 2, convertible: false, mileage: 88000, started: false, start: function() { this.started = true; }, stop: function() { this.started = false; }, drive: function() { if (this.started) { alert(this.make + " " + this.model + " goes zoom zoom!"); } else { alert("You need to start the engine first."); } } }; fiat.start(); fiat.drive(); for (prop in fiat) {//迭代对象中的每个属性 console.log(prop + ": " + fiat[prop]); } </script> </head> <body> </body> </html>