I have this simple code.
I can’t understand why in the first two cases the output is window
and in the third it is an object.
var person = {
name: "jason",
a: this,
b: console.log(this),
c: function () {
console.log(this);
},
};
console.log(person.a); // output Window {window: Window, self: Window, document: document, name: 'global', location: Location, …}
person.b; // output Window {window: Window, self: Window, document: document, name: 'global', location: Location, …}
person.c(); // output {name: 'jason', a: Window, b: undefined, c: ƒ}
2