Questions about deep comparison of objects have been asked, and I have the solution. But there is a line in the solution that I don\'t completely understand.
This is the
The in
operator returns true if the object on the right of the expression contains a key with the value of the string on the left of the expression.
Eg: prop in a
is true if a
contains a key with the same name as the string value of prop
. Eg:
var prop = "age";
var obj1 = {
name: "Dave",
age: 21,
record: { ... }
};
var obj2 = {
name: "John",
record: { ... }
};
console.log(prop in obj1); // true
console.log(prop in obj2); // false
If prop
was set to "record"
then deepEqual(a[prop], b[prop])
recursively compares the values in a.record
and b.record
.