Created
August 31, 2017 07:39
-
-
Save waaronking/cad5bfa12c1466fdc53242350d707844 to your computer and use it in GitHub Desktop.
Recursively removes a key deep in an object
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
function removeKeys(obj, key) { | |
for (const prop in obj) { | |
if (prop.toString() === key.toString()) { | |
delete obj[prop]; | |
} else if (typeof obj[prop] === 'object') { | |
this.removeKeys(obj[prop], key); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment