Utility remove nulls from object
October 19, 2023 · 1 min readLucian CiobanuJust wanted to take note of a cute little util I've been using lately to remove nulls from objects.
export function removeNulls(obj: any): any {
const copy = {...obj};
Object.keys.(copy).forEach(
(key) => (copy[key] === null && delete copy[key]);
return copy;
}
I just love how concise it is.
Hope this helps!
Cheers,
Lucian!

Web Development & Software Delivery