我使用以下代码打印所有人的信息:
<!DOCTYPE html>
<html>
<body>
<p id="demo"></p>
<script>
var txt = "";
var person = [{fname:"John", lname:"Doe", age:25},
{fname:"Hasan", lname:"Doe", age:26}];
var x;
for (x in person) {
txt += person[x] + " ";
}
document.getElementById("demo").innerHTML = txt;
</script>
</body>
</html>
但是结果是:
[对象对象] [对象对象]
为什么会这样?