Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

javascript object remove empty properties

removeEmpty(obj: any): any {
    return Object.fromEntries(
      Object.entries(obj)
        .filter(([_, v]) => v != null)
        .map(([k, v]) => [k, v === Object(v) ? this.removeEmpty(v) : v])
    );
  }
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #javascript #object #remove #empty #properties
ADD COMMENT
Topic
Name
1+2 =