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

222
Vistas
Better way to fill variables from array (Destructuring assignment)

I have this Code in my Javascript File:

const blfTypeAndId = DDid.split("PrerequisitesSelect");
const blfType = blfTypeAndId[0];
const blfId = blfTypeAndId[1];

The blfType is after this either 'block', 'line' or 'field' and the blfId is _B1_L1_F1 while the numbers can be different (this is just for field, for line it would be _B1_L1 and block just _B1)

In a world where Python and Javascript are combined I would just do this:

const blfType, const blfId = DDid.split("PrerequisitesSelect");

Is there a nice way in Javascript to still do this in one line or is my first written code already the best possible solution?

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

0

A good job for the Destructuring Assignment

const blfTypeAndId = DDid.split("PrerequisitesSelect");
const [blfType, blfId] = blfTypeAndId;

or even just

const [blfType, blfId] = DDid.split("PrerequisitesSelect");
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