运行 ❯
获取您
自己
的网站
×
更改方向
保存代码
更改主题,深色/浅色
转到 Spaces
<!DOCTYPE html> <html> <body> <h2>Access Nested JavaScript Objects</h2> <p id="demo"></p> <script> const myObj = { "name":"John", "age":30, "cars": { "car1":"Ford", "car2":"BMW", "car3":"Fiat" } } document.getElementById("demo").innerHTML = myObj.cars.car2; </script> </body> </html>