The type of the object to be pruned, which extends an object.
The object or array to prune.
Optionaloptions: PruneObjectOptionsConfiguration options.
The pruned object or array with undefined values removed.
pruneObject({ a: 1, b: undefined, c: { d: undefined } }); // Returns: { a: 1, c: {} }
pruneObject([1, undefined, { a: undefined }, [undefined]]); // Returns: [1, {}]
pruneObject([undefined, undefined]); // Returns: []
pruneObject({ date: new Date() }); // Returns: { date: DateInstance }
pruneObject({ a: { b: undefined } }, { deep: false }); // Returns: { a: { b: undefined } }
pruneObject({ a: [1, undefined] }, { arrays: false }); // Returns: { a: [1, undefined] }
Recursively removes
undefinedvalues from an object or array. This function cleans nested objects and arrays, ensuring that no properties or elements are left with the valueundefined.