npm install --save remove-undefined-objects
import removeUndefinedObjects from 'remove-undefined-objects';
console.log(removeUndefinedObjects({key: [], key2: 123}));
// { key2: 123 }
Any items with the following value will be removed:
- Empty object,
{}
- Empty array,
[]
- Undefined,
undefined
The following items will NOT be removed:
- Empty string,
''
- Null,
null