function Item(id, name) {
  this.id = id;
  this.name = name;
}

var arr = new Array(8);
arr[0] = new Item('001', 'AAA');
arr[1] = new Item('002', 'BBB');
arr[2] = new Item('003', 'CCC');
arr[3] = new Item('004', 'DDD');
arr[4] = new Item('005', 'EEE');
arr[5] = new Item('006', 'FFF');
arr[6] = new Item('007', 'GGG');
arr[7] = new Item('008', 'HHH');

for (var i in arr) {
  document.write(arr[i].id + ' - ' + arr[i].name + '<br>');
}

/* 显示结果如下:
001 - AAA
002 - BBB
003 - CCC
004 - DDD
005 - EEE
006 - FFF
007 - GGG
008 - HHH
*/


posted on 2009-02-28 21:33  万一  阅读(1818)  评论(12编辑  收藏  举报