维科纳蒂 »
×
改变方向
在 Codepen 上打开
更改主题,深色/浅色
<!DOCTYPE html> <html lang='uk'> <body> <p>Змінити значення об’єкта:</p> <p id="demo"></p> <script> let x = ""; let myObj = { "name":"John", "age":30, "cars": { "car1":"Ford", "car2":"BMW", "car3":"Fiat" } } myObj.cars.car2 = "Mercedes"; for (let i in myObj.cars) { x += myObj.cars[i] + "<br>"; } document.getElementById("demo").innerHTML = x; </script> </body> </html>