title: Check if key exists in JSON response within map function
body: <p>For instance, I receive a JSON response:</p>
  
  <pre><code>[
    {
      'key_1': 'value1A',
      'key_2': 'value2A',
      'key_3': 'value3A'
    },
    {
      'key_1': 'value1B',
      'key_2': 'value2B',
    }
  ]
  </code></pre>
  
  <p>As observed, <code>key_3</code> wasn't provided in the second element of the array. Here the <code>keys</code> are the same for each object within the array.</p>
  
  <p>Lets say, I am interested in only using <code>key_2</code> and <code>key_3</code> of the response and hence I use <code>map</code> as follows </p>
  
  <pre><code>this.serv.getInfo(code) // HTTP GET service
    .subscribe(res =&gt; {
      this.data = res.map(el =&gt; { // only use necessary key:value pairs
        let _out = { // make an object to return
  
          'new_key_1': el.key_2
          'new_key_2': '' // if there is no key_3 then leave it empty
  
        }
        if ('key_3' in el) { // if this pair exists then add it..
  
          _out['new_key_2'] = el.key_3
          return _out;
  
        }
  
        return _out; // if not return with empty string
      });
    });
  </code></pre>
  
  <p>This works well as the JSON Response is small in this case. But I assume the <code>if(.. in el)</code> checks may increase many fold if the JSON structure would be large and complex. </p>
  
  <p>What operator would be best suited in this case for a more <em>dynamic</em> check when mapping the response to a new object. Is there even a necessity to create a temp <code>_opt</code> object within the <code>map</code> function?</p>