这是我的代码
function Person (name, age) {
this.name = name;
this.age = age;
}
var family = new Array();
family[0] = new Person("alice", 40);
family[1] = new Person("bob", 42);
family[2] = new Person("michelle", 8);
family[3] = new Person("timmy", 6);
for (i =0; i<= family.length; i++) {
console.log (family[i].name);
}
这会产生一个错误:TypeError: Cannot read property 'name' of undefined
谁能从这里指出我正确的方向?