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

99
Vistas
how to remove {} empty field in array .. nodejs

i am using below code...but if Status is Empty iss show below result in database...i want to remove if Status is Empty ..

1 Address {}, Status {} save in database.

function CheckStatus(oldJob, newJob) {
  var obj = {};
  if(newJob && newJob.Status) { 
   obj.Status= {}; 
    if (oldJob.Status.total !== newJob.Status.total) {
      obj.Status.total = newJob.Status.total;
    }
    if (oldJob.Status.charge_description && oldJob.Status.charge_description !== newJob.Status.charge_description) {
      obj.Status.charge_description = newJob.Status.charge_description;
    }
  }
}

Mongodb

 "Job" : {
        "_id" : ObjectId("5873b352e7621d08fccc5890"),
        "updated_by" : "",
        "details" : "{\"current_status\":\"Completed\",\"address\":{},\"Status\":{}}",
        "changetype" : "Update",
        "datetime" : ISODate("2017-01-09T15:59:14.202Z")
    },

please help how what enter in If Condition ( below code not working)

 if(obj.address = '{}')
  {
   console.log('Empty');

  }
over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

Setting an object's value to undefined essentially removes them. You can easily use the undefined keyword like so:
newJob.address = undefined;

How would you search for an empty object and remove its content:

 if(Object.keys(newJob.address).length === 0) { newJob.address = undefined; }

The solution is better explained in the answers to this question:
How do I test an empty JavaScript object?

over 4 years ago · Santiago Trujillo 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