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

108
Vistas
Default behavior of destructuring assignment without brackets

What happens when the brackets are left off on the LHS (Left Hand Side) when using the destructuring assignment syntax? For example:

{
    let a,b = [1,2];
    console.log(a, b);
}
{
    let [a,b] = [1,2];
    console.log(a, b);
}

If brackets are not included, does it act equivalent to doing:

let a=undefined, b=[1,2];

Or what exactly occurs when brackets are left off?

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

0

You can declare multiple variables with a single let by separating them with a comma. So without the brackets you're effectively doing:

let a;
let b = [1, 2];
about 4 years ago · Juan Pablo Isaza Denunciar

0

When the brackets are left off on the LHS (Left Hand Side), it would become a variable assignment as you can declare multiple variables separated by a comma.

So:

let a,b = [1,2];

Is equivalent to:

let a;
let b = [1,2];

console.log(a); // undefined
console.log(b); // [1, 2]
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