Created
April 2, 2017 15:26
-
-
Save kalinchernev/cb229d17be25e8d09b7a86e9a023c6ff to your computer and use it in GitHub Desktop.
Clean object having useless values - old school
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
1 function cleanObject(obj) { | |
2 for (var propName in obj) { | |
3 if (obj[propName] === null || obj[propName] === undefined || obj[propName] === 0) { | |
4 delete obj[propName]; | |
5 } | |
6 } | |
7 } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment