W3School TIY Editor
W3School 在线教程
改变方向
暗黑模式
运行代码
<!DOCTYPE html> <html> <body> <h2>JavaScript For In</h2> <p>for in 语句可以遍历数组值:</p> <p id="demo"></p> <script> const numbers = [45, 4, 9, 16, 25]; let txt = ""; for (let x in numbers) { txt += numbers[x] + "<br>"; } document.getElementById("demo").innerHTML = txt; </script> </body> </html>