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

88
Vistas
Lodash set integer paths strange behavior

_.set() behaves strangely when setting a path which contains an integer. Here is an example:

const object = {}

_.set(object, "wavelength.415", "foo");

console.log(JSON.stringify(object))

Upon running this code, the object will look something like this:

{"wavelength":[null,null,null,null,null,etc....,"foo"]}

Is there a way around this behavior or am I doing something wrong?

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

0

This is the intended behavior (see this issue), use _.setWith() instead:

const object = {}

_.setWith(object, "wavelength.415", "foo", Object);

console.log(JSON.stringify(object))
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.21/lodash.min.js" integrity="sha512-WFN04846sdKMIP5LKNphMaWzU7YpMyCU245etK3g/2ARYbPK9Ub18eG+ljU96qKRCWh+quCY7yefSmlkQw1ANQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>

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