Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

113
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda