Last active
July 16, 2021 20:46
-
-
Save tim-phillips/d5bb26d1ab234aef992f6379a3a3cf62 to your computer and use it in GitHub Desktop.
removes keys with null values
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 removeNulls (obj) { | |
Object.keys(obj).forEach(key => { | |
if (obj[key] && typeof obj[key] === 'object') removeNulls(obj[key]) | |
else if (obj[key] == null) delete obj[key] | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment