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

137
Views
Filter Array of Inner Arrays Based on Inner Array Length

I need to filter out the empty arrays inside the array called arr.

Here's what I see when I console.log([arr]):

enter image description here

I have tried console.log([arr].filter(arr => arr.length > 0)) with no luck (getting [])

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

As was pointed out by @robin-zigmond, you are dealing with an object here containing array properties.

You can use the delete operator to delete properties from an object:

for (let prop in arr) {
  if (arr[prop].length === 0) {
    delete arr[prop];
  }
}

This will remove all zero-length properties from the arr object.

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!