Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

128
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!