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

162
Visualizações
Why does this statement does not throw an error?

We all know that JavaScript reserved keywords cannot be used as variable names. For example, var, function, let, etc are considered special keywords in JavaScript. But consider this code:

var let = "Hi";
console.log(let); // prints out "Hi"
let var = "Hi";
console.log(var); // Syntax error

I am confused as to why the browser did not throw an error when I attempted to use it as variable name, but when I tried with var, it throws an error.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

const and let are recent additions to JS, but for a long time before they were added const was a reserved keyword (presumably on the basis that it was thought to be a likely future addition to the language).

Since let used to be a valid variable name, this is presumably for backwards compatibility.

var let is ok but let let isn't?

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