'remove null value while destructoring the data in node js / javascript

I am trying to destructing the function to fetch the return data and store it in and Array

id: data.id,
title: data.title,
otherDetails:[
   {
     name:"dummy name",
     fields: "testing",
     production: "not yet",
   },
   {
     add:"New York",
     core: "mech",
     position: "junior",
   },
   ...arrayObj(data);
]

so I am getting the output as

id: data.id,
title: data.title,
otherDetails:[
   {
     name:"dummy name",
     fields: "testing",
     production: "not yet",
   },
   {
     add:"New York",
     core: "mech",
     position: "junior",
   },
   null,
   {
     user_id: "[email protected]",
     user_name: "firstname",
   },
   null,
   {
     userschema: "personal",
     access: "yes",
   }
   {
     nominie: "testing",
     age: "18"
   }
]

Is there any possible way when I destructor the data the null value get removed I know I am returning the null value but I want to remove the Null value when I am destructing the data



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source