for, foreach

팡태(❁´◡`❁)·2022년 2월 11일
0

3rd_20220124

목록 보기
14/29
        // for => [{ 0 }. { 1 }, { 2 }] => 위치를 i로 반복
        for(let i=0; i<result.length; i++) {
            result[i]['imageUrl'] = `/shop/image?code=${result[i]._id}`;
        }

        // foreach => [{  }, {  }, {  }] => 내용을 tmp로 반복
        for(let tmp of result) {
            tmp['imageUrl'] = `/shop/image?code=${tmp._id}`;
        }

0개의 댓글