This question has already been answered:
- Loss of context call 5 responses
var obj = { name: 'cc', trade: function() { console.log(this.name); //cc } }; obj.trade(); var obj = { name: 'cc', trade: function() { console.log(this); //name, trade (function() { console.log(this); //window, в этом и вопрос, почему, //ведь эта функция выполняется внутри метода объекта })(); } }; obj.trade(); Why does this function, which is inside the trade method of obj , equal to window , and not obj ?