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

190
Vistas
Can only access some javascript object keys

I am noticing strange behavior from a javascript object in my Node application. The user object is created by parsing a csv file with two columns: Email and ID. For some reason, I can only access one of the fields using the typical methods. The other field always returns undefined. I am using Node 15.12.0.

When I log the user object, it returns: { 'Email': 'email@example.com', ID: '12345' }

Curiously, the ID field does not have quotes when it is logged, but the Email field does have quotes.

I can access user.ID as usual, but user.Email returns undefined.

console.log(Object.keys(user)); // [ 'Email', 'ID' ]

console.log(user.ID); // 12345
console.log(user.Email); // undefined

console.log(user['Email']) // undefined
console.log(user["Email"]) // undefined
console.log(user.email) // undefined
console.log(user["\'Email\'"]) // undefined
console.log(user["'Email'"]) // undefined

console.log(user[Object.keys(user)[0]]) // email@example.com
console.log(Object.values(user)[0]) // email@example.com

I have tried the using JSON.parse(JSON.stringify(user)), but I get the same results as before.

The only way I can access the Email field is by using the user[Object.keys(user)[0]] or Object.values(user)[0] which is very strange to me.

I would appreciate any ideas you have to figure out whats happening here. Is there something I can do to examine the object more closely? Does the quotes around the keys indicate anything?

about 4 years ago · Juan Pablo Isaza
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