title: Array include by
body: <p>I have two arrays of objects.</p>
  
  <p>I am doing a comparison by id and availability</p>
  
  <p>For example</p>
  
  <pre><code>   let newCars = []
     cars.forEach((car) =&gt; {        
        const element = _.find(this.state.cars, function(o) {
          return (o.id === car.id &amp;&amp; (o.available &lt; car.available))
        })
        if (element) {
          newCars.push(element)
        }    
      })
  </code></pre>
  
  <p>However, I would also like to include in the newCars array the elements that are not present in this.state.cars, but compared only by id.</p>
  
  <p>For example, if cars has {id: 1, available: 4}, and this.state.cars has {id: 1, available: 5}, the would count as being present in both arrays and not be returned.</p>
  
  <p>In summary, I need all the elements in cars for which car.available > car.available for the element with the same id in this.state.cars, plus, all the elements in cars which are not included in this.state.cars doing the comparison inclusion by id only.</p>
  
  <p>Is this possible? (Uisng lodash or plain js)</p>
  
  <p>Thank you</p>