Q:

Why the filter output is different when I use debug ？

I want to filter some data by using 'filter', but the output data is being changed, and when I try debugging to find the reason, the output data is right ...
I already tried to use 'JSON.parse(JSON.stringify(data))' to make it work, but it failed TAT.
let needGenerateDate = sDate.data.filter(item => {
  return item.week !== week;
});
console.log("needGenerateDate", needGenerateDate);

the JSON.stringify(sDate.data) is 
"data": [
  {
      "person": [
          "person1",
          "person2",
          "person3"
      ],
      "_id": "5ca1a9bdf52c0a5710012415",
      "eventName": "special2",
      "eventNote": "没有留言呦",
      "eventType": "special",
      "week": 13,
      "time": "Sun,Mon,Wed,Tue",
      "__v": 0
  },
  {
      "person": [
          "person1",
          "person2",
          "person3",
          "person2",
          "person3"
      ],
      "_id": "5ca1ae5cd182b35534c89174",
      "eventName": "special1",
      "eventNote": "没有留言呦",
      "eventType": "special",
      "week": 13,
      "time": "Sun,Mon,Tue,Sat",
      "__v": 0
  }
]

When I debug the result is like this
enter image description here
but without debugging, the result is like this
enter image description here
I want the first one
please help a child QAQ

A:

You can use a simple Set to get unique items, then flatten the array:

const sDate = {
  "data": [{
      "person": [
        "person1",
        "person2",
        "person3"
      ],
      "_id": "5ca1a9bdf52c0a5710012415",
      "eventName": "special2",
      "eventNote": "没有留言呦",
      "eventType": "special",
      "week": 13,
      "time": "Sun,Mon,Wed,Tue",
      "__v": 0
    },
    {
      "person": [
        "person1",
        "person2",
        "person3",
        "person2",
        "person3"
      ],
      "_id": "5ca1ae5cd182b35534c89174",
      "eventName": "special1",
      "eventNote": "没有留言呦",
      "eventType": "special",
      "week": 13,
      "time": "Sun,Mon,Tue,Sat",
      "__v": 0
    }
  ]
};

let needGenerateWeek = [...new Set(sDate.data.flatMap(({ person }) => person))];
console.log(needGenerateWeek);

