W3School TIY Editor
W3School 在线教程
改变方向
暗黑模式
运行代码
<!DOCTYPE html> <html> <body> <h1>JavaScript 对象属性</h1> <p>您可以向现有对象添加新属性。</p> <p id="demo"></p> <script> var person = { firstname:"Bill", lastname:"Gates", age:62, eyecolor:"blue" }; person.nationality = "English"; document.getElementById("demo").innerHTML = person.firstname + " is " + person.nationality + "."; </script> </body> </html>