filtrar indefinido do objeto JavaScript
const obj = {key1: undefined, key2: '', key3: 0, key4: null}
Object.keys(obj).forEach(key => obj[key] === undefined ? delete obj[key] : {});
// obj is now without key1 i.e. {key2: '', key3: 0, key4: null}
Anxious Alligator