The object or array to clean.
The cleaned object or array.
cleanDeep({
foo: null,
bar: undefined,
baz: '',
qux: NaN,
quux: [],
corge: {},
grault: { garply: BigInt(123), waldo: null, fred: true, plugh: undefined, xyzzy: 'Hello, World!' },
thud: ['', 123, NaN, new Date(0), []],
})
// => { grault: { garply: BigInt(123), fred: true, xyzzy: 'Hello, World!' }, thud: [123, new Date(0)] }
Recursively cleans an object or array by removing properties with
null
,undefined
, empty string,NaN
, empty arrays, or empty plain objects.