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

142
Vistas
Convert string array element to JS object

I'm trying to convert string to object with the below code:

wishlisted= [ '626601b89f1c16d0e42fd58e' ]
console.log(wishlisted.map(id => ({ id })));

Output for this came as:

[ { id: '626601b89f1c16d0e42fd58e' } ]

But from the output, I think id is of String type. I want to return it just like MongoDB's id, like: 626601b89f1c16d0e42fd58e, not as a string.

When I tried to check the type of id using:

console.log(typeof wishlisted[0].id);

it came as undefined. What could be the best way to do this type casting?

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