I have an object with some very specific keys. How can I check if another object has exactly the same keys? For example:
let myOb = {
name: "somebody",
class: {
number: 9,
section: "C"
},
address: {
house: 22,
street: "Eg street"
PIN: 7893
}
}
if (newOb.containsAll(myOb)) { // this is just a replacement function
// do stuff
}
I want to match the newOb to myOb and see if they have the exact keys. So, newOb should have a name, class, address; newOb.class should have a number and section; newOb.address should have a house, street and PIN.
I am already aware of hasOwnProperty(). I want to know if there is a easier way to do this were multiple keys are involved.