Created
April 24, 2019 15:41
-
-
Save jeremyckahn/40d6282e7bb329d42ec25c849e9dd297 to your computer and use it in GitHub Desktop.
Compute keys that are different between two JS objects
This file contains hidden or 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
/** | |
* @param {Object} oldData | |
* @param {Object} newData | |
* @returns {Array.<string>} A list of key names that are different between | |
* oldData and newData. | |
*/ | |
export const getChangedProperties = (oldData, newData) => | |
Object.keys(oldData).reduce( | |
(acc, key) => (oldData[key] !== newData[key] ? [...acc, key] : acc), | |
[] | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment