Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

lodash remove undefined values from object

var person = {"name":"bill","age":21,"sex":undefined,"height":"crap"};
//remove undefined properties or other crap
var cleanPerson = _.pickBy(person, function(value, key) {
  return !(value === undefined || value === "crap");
});
//cleanPerson is now { "name": "bill","age": 21}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #lodash #remove #undefined #values #object
ADD COMMENT
Topic
Name
7+9 =