I have an object like this:
const obj = {
name: "one",
created: "2022-05-05T00:00:00.0Z",
something: {
here: "yes"
}
}
I can check if it has certain attributes one by one:
assert( obj.name !== undefined && obj.name === "one")
assert( obj.something !== undefined && obj.something.here !== undefined && obj.something.here === "yes")
Is there a way to achieve the same passing another object to compare? The other object would have less values (in this example I don't care if the created
attribute is present)
Something like:
const obj = {
name: "one",
created: "2022-05-05T00:00:00.0Z",
something: {
here: "yes"
}
}
hasAllOf(obj, {
name: "one",
something: {
here: "yes"
}
}) // returns true
Either with lodash or some other library?