Fill Array with Objects

How to fill an Array with objects

by Couto

JavaScript

//Create a new Object, that will serve as a blueprint
function Person(firstname, lastname, age, eyecolor){
    this.firstname = firstname;
    this.lastname = lastname;
    this.age = age;
    this.eyecolor = eyecolor;
}
//Create the Array with People
//And then fill the array with the Object Person =)
var PessoasArray = []; 
    PessoasArray[0] = new Person("Zé", "António", 50, "Azul");
    PessoasArray[1] = new Person("João", "Pires", 17, "Castanho");

//Outside local variable.
//Improved-native for() for performance
var i = PessoasArray.length -1;
for (i; i >= 0; i--){
    document.write(PessoasArray[i].firstname+" "+PessoasArray[i].lastname+"<br />");
};