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?
function(obj1, obj2){
    if(obj1.HasAllKeys(obj2)) {
         //do something
    }
    else{
         throw new Error(...);
    } 
};
For example in below example since FirstObject has all the SecondObject's key it should run the code :
FirstObject
{
    a : '....',
    b : '...',
    c : '...',
    d : '...'
}
SecondObject
{    
    b : '...',    
    d : '...'
}
But in below example I want to throw an exception since XXX doesnt exist in FirstObject:
FirstObject
{
    a : '....',
    b : '...',
    c : '...',
    d : '...'
}
SecondObject
{    
    b : '...',    
    XXX : '...'
}
 
     
     
     
    