W3School TIY Editor
W3School 在线教程
改变方向
暗黑模式
运行代码
<!DOCTYPE html> <html> <body> <h2>JavaScript For In Loop</h2> <p>for in 语句循环遍历对象的属性:</p> <p id="demo"></p> <script> const person = {fname:"Bill", lname:"Gates", age:19}; let txt = ""; for (let x in person) { txt += person[x] + " "; } document.getElementById("demo").innerHTML = txt; </script> </body> </html>