W3School TIY Editor
W3School 在线教程
改变方向
暗黑模式
运行代码
<!DOCTYPE html> <html> <body> <h2>JavaScript For Of 循环</h2> <p>for of 语句循环遍历任何可迭代对象的值:</p> <p id="demo"></p> <script> const cars = ["BMW", "Volvo", "Mini"]; let text = ""; for (let x of cars) { text += x + "<br>"; } document.getElementById("demo").innerHTML = text; </script> </body> </html>