Created
November 7, 2020 05:17
-
-
Save myogeshchavan97/610f5ccf4c393132dcebc7c565bb8b6e to your computer and use it in GitHub Desktop.
merge using lodash operator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const user = { | |
name: "David", | |
phone: 122345678, | |
location: { | |
city: "Camden", | |
country: "UK" | |
} | |
}; | |
const updates = { | |
name: "David", | |
phone: 123456789, | |
location: { | |
city: "Smithfield" | |
} | |
}; | |
console.log(_.merge(user, updates)); | |
/* output: | |
{ | |
name: 'David', | |
phone: 123456789, | |
location: { | |
country: 'UK', | |
city: 'Smithfield' | |
} | |
} | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment