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: 
Make a hash map out of `data` with `id` as key.

```js
let data = [
        {id: 1, name: "Carl", city: "New York"},
        {id: 2, name: "Anna", city: "New York"},
        {id: 3, name: "Carl", city: "Sydney"}
    ];
let map1 = new Map(data.map(e=>[e.id,e]));
let filterValue = [1, 2];
let output = filterValue.map(e=>map1.get(e));
console.log(output);
```
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);
```