title: Best way to Check a JavaScript Object has all the keys of another JavaScript Object
body: <p>I have two JS objects, I want to check if the first Object has all the second Object's keys and do something, otherwise, throw an exception. What's the best way to do it?</p>
  
  <pre><code>function(obj1, obj2){
      if(obj1.HasAllKeys(obj2)) {
           //do something
      }
      else{
           throw new Error(...);
      } 
  };
  </code></pre>
  
  <p>For example in below example since FirstObject has all the SecondObject's key it should run the code :</p>
  
  <pre><code>FirstObject
  {
      a : '....',
      b : '...',
      c : '...',
      d : '...'
  }
  SecondObject
  {    
      b : '...',    
      d : '...'
  }
  </code></pre>
  
  <p>But in below example I want to throw an exception since XXX doesnt exist in FirstObject:</p>
  
  <pre><code>FirstObject
  {
      a : '....',
      b : '...',
      c : '...',
      d : '...'
  }
  SecondObject
  {    
      b : '...',    
      XXX : '...'
  }
  </code></pre>