随笔 - 2146  文章 - 97 评论 - 11767 trackbacks - 253


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  万一  阅读(...)  评论(...编辑  收藏