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

216
Vistas
single quotes for string keys in javascript object

In nodejs I was creating a list of objects with each object supposed to have a string key and a number as value. I am able to create this without issues but while trying to log this with console.log() . I could see some keys did not have a single quotes surrounding the key while some did.

eg

[
    { '2d22f294': 0 },    
    { b6d108da: 0 },
    { b17562ff: 0 },
    { '0e4a0beb': 0 }
  ]

Could anyone explain what does it mean to have a single quotes surrounding the key , I was of the assumption this meant the key was a string but even the ones without single quotes around the keys are strings and act like strings.

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

If it's starts with a number, then printing must show you valid javascript and quotes tell you that the key is a string (not a number).

about 4 years ago · Juan Pablo Isaza Denunciar

0

If you have an object like this

let object = {
    name: 'Jim',
    25: 'Age'
}

You can access the properties in the following way:

  • for the namekey ... object.name or object['name'].

  • for the key 25 ... object[25] or object['25']

This is because properties cannot start with a number in js. Therefore you have to access them with brackets.

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