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
According to MDN:
The in operator returns
true
if the specified property is in the specified object.
Also:
The for...in statement iterates over the enumerable properties of an object, in arbitrary order. For each distinct property, statements can be executed.
So to answer your first question, prop in a
is checking whether prop
, a field from object b
, exists in object a
.
To answer your second question, deepEqual(a[prop], b[prop])
is checking whether the object a[prop]
and b[prop]
are equal including all its children and contents.