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

113
Views
How to check one of my object value is empty or not

I need to check my java object value is empty or not. And I need to check this one by one. I crate my code to do this task...But I can't check values one by one. If all of my object value is empty, my code is working...But it can't check values one by one.

const coverDesc = action.data.coverDescriptionLocalization;

enter image description here

Methord 01- :-

 if (Object.values(coverDesc ).every((x) => x === null || x === '')) {
        console.log('Empty');
    } else {
        console.log('Not empty');
    }

Methord 02- :-

for (const key in coverDesc) {
    if (coverDesc.hasOwnProperty(key)) {
        if (Object.values(coverDesc[key]).every((x) => x === null || x === '')) {
           console.log('Empty');
        } else {
            console.log('Not empty');
        }
    }
}
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

If you just want to check whether there's a truthy value, you can do:

Object.keys(coverDesc).every((k) => coverDesc[k] === false)

If you need to check specifically for an empty string over null, I would think checking against "" is the best, using the === operator

Object.keys(coverDesc).every((k) => coverDesc[k] === false)
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!