Skip to content

Instantly share code, notes, and snippets.

@sscotth
Created March 3, 2020 01:19
Show Gist options
  • Save sscotth/8ab1a8d175adcf1424d143204bab2108 to your computer and use it in GitHub Desktop.
Save sscotth/8ab1a8d175adcf1424d143204bab2108 to your computer and use it in GitHub Desktop.
Strip Undefined properties
// const obj = { a: undefined, b: 2, c: 0, d: null, e: 0.3, f: "", g: false }
Object.fromEntries(Object.entries(obj).filter(([k, v]) => v != null))
// => {b: 2, c: 0, e: 0.3, f: "", g: false}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment