title: JavaScript filter array of objects based on property values
body: <p>I have an array of objects in javascript. The contents look like this;</p>
  
  <pre><code>obj_array = [{
          "DATA_ID": 1,
          "DATA_NAME": "Dim",
          "DATA_BB_TYP": 2,
          "DATA_MAC": "5474",
      },
      {
          "DATA_ID": 3,
          "DATA_NAME": "Spre",
          "DATA_BB_TYP": 33,
          "DATA_MAC": "8e30",
      },
      {
          "DATA_ID": 2,
          "DATA_NAME": "Dimb",
          "DATA_BB_TYP": 2,
          "DATA_MAC": "45e8",
      },
      {
          "DATA_ID": 4,
          "DATA_NAME": "Kht1",
          "DATA_BB_TYP": 35,
          "DATA_MAC": "58d0",
      },
      {
          "DATA_ID": 6,
          "DATA_NAME": "Sens",
          "DATA_BB_TYP": 34,
          "DATA_MAC": "d004",
      }
  ]
  </code></pre>
  
  <p>I want to retain some objects and remove the rest. If the object property <code>DATA_BB_TYP</code> is 2 or 34, the objects will be retained. THe other objects are removed. The outcome of the <code>obj_array</code> will look like this;</p>
  
  <pre><code>obj_array_retained = 
  [{
          "DATA_ID": 1,
          "DATA_NAME": "Dim",
          "DATA_BB_TYP": 2,
          "DATA_MAC": "5474",
      },
      {
          "DATA_ID": 2,
          "DATA_NAME": "Dimb",
          "DATA_BB_TYP": 2,
          "DATA_MAC": "45e8",
      },
      {
          "DATA_ID": 6,
          "DATA_NAME": "Sens",
          "DATA_BB_TYP": 34,
          "DATA_MAC": "d004",
      }
  ]
  </code></pre>
  
  <p>I am using node.js v6.91. </p>
  
  <p>EDIT: Someone suggested to me using filter to solve this kind of problem. Answers using filter technique would be most welcomed.</p>