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?