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

155
Visualizações
'this' in JavaScript behaves differently in node and chrome console

running the same code in different environments produces different results1

try running the code below in chrome console and on node js, the first produces snehal snehal and the other undefined undefined

this.name = "snehal";

function meme() {
  console.log(this.name);
  function mem() {
    console.log(this.name);
  }
  mem();
}

meme(); 

The basic idea about this in JavaScript is that it points/refers to the object that contains it, so in the chrome console we can expect the inner mem function this to be === to the meme function this, but the same is not consistent in the node environment.

about 4 years ago · Juan Pablo Isaza
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