Trying to filter the object to return only non null values.
Below is excerpt from my code. How do I check for non null values in the array job in this case?
const name = null,
age = '25',
job = [null];
const obj = {
name,
age,
job
};
const result = Object.fromEntries(
Object.entries(obj).filter(([_, value]) => value)
);
console.log(result)
Could anyone please help?
I was expecting the result to be
{
"age": "25"
}
!![]. And even if empty arrays were falsy, yours is not emptytypeoffor each value and if it is an array then traverse through the array and check.['developer', null]? Would you want to reject that array or keep it?['developer']@Terry