Home

WayneCarl Barker's Portfolio/ Blog

Go Back

Function to filter undefined or null keys

March 24, 2023
export const cleanUndefinedOrNullKeys = <T>(obj: Object) => (
    Object.fromEntries(
        Object.entries(obj).filter(([k, v]) => v != null || v != undefined)
    )) as T;