Created
October 10, 2016 06:47
-
-
Save kbshl/64df90c5a22d68598f9af18cde10b432 to your computer and use it in GitHub Desktop.
Remove empty properties falsy values from object with Underscore >= 1.7.0 or Lodash From http://stackoverflow.com/questions/14058193/remove-empty-properties-falsy-values-from-object-with-underscore-js
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
var cleanedObj; | |
// Underscore >= 1.7.0 | |
cleanedObj = _.pick(sourceObj, _.identity); | |
// Lodash >= 0.1.0 | |
cleanedObj = _.pick(sourceObj, _.identity); | |
// Lodash >= 4.0.0 | |
cleanedObj = _.pickBy(sourceObj); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
thanks)