I have a script like this:
var test = function(){
console.log('From test: ' + this);
};
console.log(this);
test();
Which I run using node test.js. And what I would expect from the script is for both this to point to global object, however only this within the test function points to global object.
console.log(this); actually points to an empty object.
I am trying to understand why node.js has this behaviour and am I misunderstanding something about how this keyword works in node.js.