큰 오브젝트 리스트의 빠른 탐색을 위한 해쉬테이블 형태 사용
var score = [];
score[score.length] = {user:"u1", type:"left", total:230};
score[score.length] = {user:"u2", type:"right", total:215};score[score.length] = {user:"u3", type:"right", total:283};
...score[score.length] = {user:"u8", type:"left", total:370};
score[score.length] = {user:"u9", type:"left", total:198};
for (var i = 0; i < score.length; i++) {
score[score[i].type + "_" + score[i].user] = score[i];
}
sales["right_u3"].total // 283
→ 전체를 탐색하지 않고 값에 직접 접근이 가능.
[이 게시물은 관리자님에 의해 2011-10-31 17:16:08 PHP & HTML에서 이동 됨]
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기