성능향상을 위한 팁-4
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
→ 전체를 탐색하지 않고 값에 직접 접근이 가능.
댓글 1개
for문에 새로운 배열 만들어주는거 score가 아니라 sales[score[i]....