Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

111
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda