为什么下面的 javascript 代码对我不起作用?我应该在下面的代码中进行哪些更改?
function person(firstname, lastname, age, eyecolor)
{
this.firstname = firstname;
this.lastname = lastname;
this.age = age;
this.eyecolor = eyecolor;
}
for(var i = 0; i < 10; i++)
{
myFather[i] = new person("John", "Doe", i, "blue");
}
for(var i = 0; i < 10; i++)
{
document.write(myFather[i].firstname + " is " +
myFather[i].age + " years old.");
}