4
Assuming I have the following objects:
const dataBody = { name:'luiz', email:'[email protected]', cpf:'12345678910' }
const dataDb = { name:'luiz', email:'[email protected]', cpf:'12345678910' }
How do I compare each property of the two objects, and create a new one, with the value(s) of the first one, only when the property(s) is((s) different(s)?
This would be the new object:
const dataRes = { email: '[email protected]'}
for dataBody.email != dataDb.email
Would the new object have only one property? The other data will be lost even?
– Daniel Mendes
The new object would have all the properties that were different between the two compared objects.
– Beto Garcia
Cool, so the @Lleon answer already fits you! = D
– Daniel Mendes