I copied the code from YDKJS and the authors expected output is 'oops global', but when I run this in Node, I am getting 'undefined'. Why?
function foo() {
console.log(this.a);
}
var obj = {
a: 2,
foo: foo
};
var bar = obj.foo; // function reference/alias!
var a = "oops, global"; // `a` also property on global object
bar(); // "oops, global"