title: How to filter js object array based on multiple parameters
body: <p>I have the following js array:</p>
  
  <pre><code>var arr= [{id: "123", name: "Foo"},
            {id: "123", name: "Bar"},
            {id: "345", name: "Foo"},
            {id: "678", name: "FooBar"}
           ];
  </code></pre>
  
  <p>I have an onclick event where I get the id and name of the clicked element.</p>
  
  <pre><code>var name = $( this ).data('name');
  var id = $( this ).data('id');
  </code></pre>
  
  <p>And this is the function I'm using to remove the elements from the array.</p>
  
  <pre><code>arr = arr.filter( function(elem) { 
                                   return elem.id != id 
                                   &amp;&amp; elem.name != name;
                                   });
  </code></pre>
  
  <p>If I use just the id or just the name in the filter function it works, but together they don't work. If the clicked item had id-123 and name-Foo then all elements (that have either id-123 or name-Foo) are removed and I'm left with </p>
  
  <pre><code>var arr= [{id: "678", name: "FooBar"}
           ];
  </code></pre>
  
  <p>and I need just the one containing both to only be removed so the result should be:</p>
  
  <pre><code>var arr= [
            {id: "123", name: "Bar"},
            {id: "345", name: "Foo"},
            {id: "678", name: "FooBar"}
           ];
  </code></pre>