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

127
Vistas
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 Respuestas
Responde la pregunta

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 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