Question: I have 2 values, I want to filter those values ​​in my data. How can I do it?

I want to filter the ids 1 and 2.

```
    data: [
            {id: 1, name: "Carl", city: "New York"},
            {id: 2, name: "Anna", city: "New York"},
            {id: 3, name: "Carl", city: "Sydney"}
        ]

    filterValue: [1, 2]

```

Answer: 
You can use `.filter()` with `.includes()` to check whether or not `obj.filterValue` has the current objects `id`, if it doesn't, you can keep the array, if it does, it will remove it from the new array:

```js
const obj = {data:[{id:1,name:"Carl",city:"New York"},{id:2,name:"Anna",city:"New York"},{id:3,name:"Carl",city:"Sydney"}],filterValue:[1,2]};
const res = obj.data.filter(({id}) => !obj.filterValue.includes(id));

console.log(res);
```
You can use .filter() on Array:

```
var data = [{
    id: 1,
    name: "Carl",
    city: "New York"
  },
  {
    id: 2,
    name: "Anna",
    city: "New York"
  },
  {
    id: 3,
    name: "Carl",
    city: "Sydney"
  }
]

var filteredData = data.filter(function(data) {     
    return data.id == 1 || data.id == 2;
})

```