运行 ❯
获取您
自己的
网站
×
更改方向
保存代码
更改主题,深色/浅色
转到空间
<!DOCTYPE html> <html> <body> <h1>Creating JavaScript Objects</h1> <h2>Using an Object Literal</h2> <p id="demo"></p> <script> // Create an Object: const person = { firstName: "John", lastName: "Doe", age: 50, eyeColor: "blue" }; // Display Data from the Object: document.getElementById("demo").innerHTML = person.firstName + " is " + person.age + " years old."; </script> </body> </html>