Skip to content

Instantly share code, notes, and snippets.

@hecomi
Last active January 13, 2016 13:02
Show Gist options
  • Save hecomi/38f2fffb5c8269f22b09 to your computer and use it in GitHub Desktop.
Save hecomi/38f2fffb5c8269f22b09 to your computer and use it in GitHub Desktop.
'use strict';
var removeKeysRecursively = (obj, prop) => {
if (!obj) return;
if (typeof obj === 'object') {
delete obj[prop];
for (let key in obj) {
removeKeysRecursively(obj[key], prop);
}
} else if (Array.isArray(obj)) {
obj.forEach(elem => removeKeysRecursively(elem, prop));
}
};
module.exports = removeKeysRecursively;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment