JS class without constant reference to “this” for member access
问题 My typical JS class structure looks like this: MyClass = function(args) { this.myProp1 = undefined; this.myProp2 = args[0]; //...more member data this.foo = function() { return this.myProp1 + this.myProp2; //<- the problem. } //...more member functions } //if MyClass extends a superclass, add the following... MyClass.prototype = Object.create(MySuperClass.prototype); MyClass.prototype.constructor = MyClass; ...My ongoing annoyance with JS is that I seem to have to use this continuously in