배열에서 특정 요소를 제거하고 개별 요소를 내보내고 싶을 땐 reduce

null·2022년 4월 7일
0
      for (let i = 1; i < orderedCheckedPopups.length; i++) {
        const checked = orderedCheckedPopups[i];
        const originalIndex = displayList.findIndex((item) => item.id === checked.id);
        if (originalIndex >= 0 && originalIndex <= afterDraggingIndex) {
          hiddenCount += 1;
        }

이렇게 된 for문
첫 번째 요소만 제거해서 하는게 필요했다.

      const checked = orderedCheckedGoods.reduce((prev: any, item: any) => item);

prev 첫 번째 요소 제거하고 바로

profile
개발이 싫어.

0개의 댓글