Entry
How to create structured data array
May 19th, 2000 05:14
Hiroto Sekine, https://buttons.ihug.co.nz/all/mu2iafdemo.htm
function Person( name, age, sex ){
this.name = name;
this.age = age;
this.sex = sex;
}
function makeStudentArray(){
var i = 0;
this[i++] = new Person( "John", 22, "male" );
this[i++] = new Person( "Mary", 28, "female" );
this[i++] = new Person( "Smith", 41, "male" );
this[i ] = null;
this.length = i;
}
var STUDENT = new makeStudentArray();
var loop = STUDENT.length;
for (var i=0; i<loop; i++){
if (STUDENT[i].age < 25){
// perform something
} else {
// perform something
}
}