I have below piece of code in test.js file
function foo(){
console.log(this.bar);
}
var bar = "bar1";
var obj = {bar: "bar2"};
foo();
foo.call(obj);
when I run by 'node test.js', I got result
undefined
bar2
when I run in node .editor, I got result
bar1
bar2
I think the second result is right, but what is wrong with the first way? cuz I always do the first way.
what are the differences between them?
node .editor, is it REPL mode?