I am kinda new to JavaScript, so was just learning about "this" pointer, I tried to use the apply() to change the context of an object, I ran the code in NodeJS REPL, and the output was undefined and undefined.
var word="Hello";
var obj={word:"GB"};
function foo(){return this.word;}
console.log(foo());
foo.apply(obj);
console.log(foo());
And I ran the same in chrome browser, It output Hello and Hello, using apply(), the output was supposed to be Hello and GB.
I am confused about this usage. Please help.