Skip to content

Instantly share code, notes, and snippets.

@phaedryx
Created February 5, 2012 18:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save phaedryx/1747038 to your computer and use it in GitHub Desktop.
Save phaedryx/1747038 to your computer and use it in GitHub Desktop.
var Student;
var students;
var student1;
var student2;
var i, len, student;
Student = (function() {
function Student(fname, lname) {
this.firstName = fname;
this.lastName = lname;
}
return Student;
})();
students = [];
student1 = new Student('Paul', 'Jones');
student2 = new Student('Jane', 'Smith');
students.push(student1);
students.push(student2);
for (i = 0, len = students.length; i < len; i++) {
student = students[i];
document.write(student.firstName + ' ' + student.lastName + '<br>');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment