Created
August 29, 2019 13:58
-
-
Save LexVocoder/dc3bd07142391202b6e13a14655f81b2 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 cloneThenDeleteNullValues(obj: object) { | |
const res = Object.entries(obj).reduce((acc: object, [k, v]) => { | |
if (typeof v !== 'undefined' && v != null) { | |
acc[k] = v; | |
} | |
return acc; | |
}, {} as object); | |
return res; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment