x
 
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript 在循环中显示对象</h1>
<p>可以在循环中收集对象的属性</p>
<p id="demo"></p>
<script>
const person = {
  name: "Bill",
  age: 19,
  city: "Seattle"
};
let txt = "";
for (let x in person) {
txt += person[x] + " ";
};
document.getElementById("demo").innerHTML = txt;
</script>
</body>
</html>