创建 JavaScript 对象
- <!DOCTYPE html>
- <html>
- <body>
- <h1>JavaScript 对象</h1>
- <p id="demo"></p>
- <script>
- // 创建对象:
- var car = {type:"porsche", model:"911", color:"white"};
- // 显示对象中的数据:
- document.getElementById("demo").innerHTML = car.type;
- </script>
- </body>
- </html>