The 'this' keyword returns the window object within an object's prototype in Javascript?
问题 I have the following function in a class: MyClass.prototype.myFunction = function(item, args) { console.log(this); } This function is called from an external library that I don't have access to change. When it's called, the console is logging "this" as the window object instead of the actual instanced object. Upon searching stackoverflow I found this quote: this is set according to how the method is called, and not according to how the method is written. So for obj.method(), this will be set