728x90

const user_list = [{ id: 1 }, { id: 2, }, { id: 1 }, { id: 3, } ];

const unique_user = user_list.reduce((prev, now) => {

  if (!prev.some(obj => obj.id !== now.id })) {

    prev.push(now);

  }

  return prev;

}, []);

728x90
반응형