테스트 사이트 - 개발 중인 베타 버전입니다
큰 오브젝트 리스트의 빠른 탐색을 위한 해쉬테이블 형태 사용

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에서 이동 됨]

댓글 작성

댓글을 작성하시려면 로그인이 필요합니다.

로그인하기

댓글 1개

오타가 있는것 같은데...
for문에 새로운 배열 만들어주는거 score가 아니라 sales[score[i]....

게시판 목록

프로그램

글쓰기