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

102
Vistas
Select an object with particular condition

Basically, I am selecting part of the object (values) and I want to inject CreateValue to this object, but with certain condition. I want to check if the field starts with a 'FLD_STR_' and if this field contain an object. I have multiple field 'fld_str_' hence the reason I want to only select the one that contains an object and not a string. I do not think I need to loop in this case. Just add a condition

const values = {
  ID: 748817,
  CODE: "OFFLINE-003",
  FLD_STR_101: {
    field: "FLD_STR_101",
    name: "doc.pdf",
    value: 'base64',
    type: "application/pdf"
  },
  FLD_STR_102: "coucou",
  Table: 109414,
  OWNER: "MJACQUIER",

}
const ele = ()=>{
  if (values.startsWith('FLD_STR_') &&
  typeof values.startsWith('FLD_STR_') === 'object') {
  values.createFileValue = values.startsWith('FLD_STR_');
  
  }
}
console.log(ele())

this is the output :

const values = {
  ID: 748817,
  CODE: "OFFLINE-003",
  FLD_STR_101: {
    field: "FLD_STR_101",
    name: "doc.pdf",
    value: 'base64',
    type: "application/pdf"
  },
  FLD_STR_102: "coucou",
  Table: 109414,
  OWNER: "MJACQUIER",
"createFileValue": {
    field: "FLD_STR_101",
    name: "doc.pdf",
    value: 'base64',
    type: "application/pdf"
  }

}
about 4 years ago · Santiago Gelvez
1 Respuestas
Responde la pregunta

0

what does values.startsWith('FLD_STR_') ? values is object not a string, try this

const keys = Object.keys(values);
keys.forEach(key => {
  if(key.startsWith('FLD_STR_') && typeof values[key] === 'object'){
    values.createFileValue = values[key];
  }
})
about 4 years ago · Santiago Gelvez 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