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() 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;
})

```