Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

84
Views
Javascript removing null or undefined object from array of objects

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?

[
  {
    "addrSeq": "12",
    "addinfo": [
      {
        "virAddrSeq": "45"
      }
    ]
  },
  null
]
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

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)

about 4 years ago · Juan Pablo Isaza Report

0

let arr = [
  {
    "addrSeq": "12",
    "addinfo": [
      {
        "virAddrSeq": "45"
      }
    ]
  },
  null
];
arr = arr.filter((i)=>i !== null && typeof i !== 'undefined');
console.log(arr);

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!