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

129
Visualizações
Node.js this keyword

According to MDN, the this keyword behaves like the following.

In the global execution context (outside of any function), this refers to the global object, whether in strict mode or not.

I test it by running these codes:

'use strict'; 
console.log(this === global);

The result is confusing. When I put those codes into a file and run it by doing node test.js, it returns false. But when I run it in repl.it, it returns true.

I expect that both ways should return true. Can anyone explain why?

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

Files in node are modules and are in their own context to avoid polluting the global namespace.

In the repl you're in its own context, which happens to be the global context.

over 4 years ago · Santiago Trujillo 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