The below format is fetching from server and its strangely adding null value in the last object. I want to remove null or undefined objecs from the array. Can anyone help me?
Sign up to request clarification or add additional context in comments.
Comments
3
You can use Array.filter to filter out null and undefined items by checking whether the item is not null (an undefined check is unnecessary, since null == undefined).
const arr=[{addrSeq:"12",addinfo:[{virAddrSeq:"45"}]},null,undefined];
const result = arr.filter(e => e != null)
console.log(result)