<!DOCTYPE html> <html> <body> <h1>JavaScript 可迭代对象</h1> <p>迭代字符串:</p> <p id="demo"></p> <script> // 创建字符串 const name = "(www.sou-xun.com)"; // 列出所有元素 let text = "" for (const x of name) { text += x + "<br>"; } document.getElementById("demo").innerHTML = text; </script> </body> </html>