Created
May 9, 2018 13:09
-
-
Save rodrigobdz/f505fe4cb20a79a9b82fa62383b1149b to your computer and use it in GitHub Desktop.
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
/** | |
* Update values only for existing keys | |
* @param {Object} outdated Object with old values | |
* @param {Object} updated Object with updated values, it may have unnecessary keys. | |
*/ | |
const updateExistingProperties = (outdated, updated) => { | |
var result = {...outdated} | |
for (let k of Object.keys(updated)) { | |
// Ignore unnecessary keys | |
if (!(k in result)) { | |
continue | |
} | |
result[k] = updated[k] | |
} | |
return result | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment