运行 ❯
获取您
自己的
网站
×
更改方向
保存代码
更改主题,暗/亮
前往 Spaces
<!DOCTYPE html> <html> <body> <h1>Creating JavaScript Objects</h1> <h2>Using the new Keyword</h2> <p id="demo"></p> <script> // Create an Object const person = new Object(); person.firstName = "John"; person.lastName = "Doe"; person.age = 50; person.eyeColor = "blue"; // Diplay Object Content document.getElementById("demo").innerHTML = person.firstName + " is " + person.age + " years old."; </script> </body> </html>