Skip to content

Instantly share code, notes, and snippets.

@myogeshchavan97
Created May 26, 2021 03:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save myogeshchavan97/fdaaddf8bf6a818cdbafa842e3f54820 to your computer and use it in GitHub Desktop.
Save myogeshchavan97/fdaaddf8bf6a818cdbafa842e3f54820 to your computer and use it in GitHub Desktop.
Merge using lodash merge
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