维科纳蒂 »
×
改变方向
在 Codepen 上打开
更改主题,深色/浅色
<!DOCTYPE html> <html lang='uk'> <body> <h2>Зациклення масиву</h2> <p id="demo"></p> <script> const myJSON = '{"name":"John", "age":30, "cars":["Ford", "BMW", "Fiat"]}'; const myObj = JSON.parse(myJSON); let text = ""; for (let i in myObj.cars) { text += myObj.cars[i] + ", "; } document.getElementById("demo").innerHTML = text; </script> </body> </html>