Skip to content

Instantly share code, notes, and snippets.

@tim-phillips
Last active July 16, 2021 20:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tim-phillips/d5bb26d1ab234aef992f6379a3a3cf62 to your computer and use it in GitHub Desktop.
Save tim-phillips/d5bb26d1ab234aef992f6379a3a3cf62 to your computer and use it in GitHub Desktop.
removes keys with null values
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