Skip to content

Instantly share code, notes, and snippets.

@Restoration
Last active September 20, 2023 22:29
Show Gist options
  • Save Restoration/b1136471015a895011ecf1886bcfd509 to your computer and use it in GitHub Desktop.
Save Restoration/b1136471015a895011ecf1886bcfd509 to your computer and use it in GitHub Desktop.
function mergeObjects(objA, objB) {
const keys = new Set([...Object.keys(objA), ...Object.keys(objB)]);
const result = {};
keys.forEach(key => {
result[key] = objB[key] !== undefined ? objB[key] : objA[key];
});
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment