xxxxxxxxxx
<!DOCTYPE html>
<html>
<title>JavaScript For 循环遍历对象的属性示例 - 基础教程(div.cn)</title>
<body>
<p>以下示例循环遍历对象的属性:</p>
<script>
var myObj = {
name: "Tiger",
age: 22,
height: 175,
city: "New Delhi",
getNothing: function () {return "";}
};
for (let x in myObj) {
document.write(x + " = " + myObj[x]);
document.write("<br>");
}
</script>
</body>
</html>