JavaScript Hapus Properti Objek Salah

const person = { 'name':'bill', 'age':21, 'sex':undefined, 'height':null, 'hasPet':false };
//only keep truthy values
const cleanPerson = _.pickBy(person, _.identity);
//cleanPerson is now { "name":"bill", "age":21 }
Merlin4 (personal)