草庐IT

AwesomeObject

全部标签

javascript - 需要模式 : create new object that returns an executeable function and inherits from a prototype

场景1-一切正常:varAwesomeObject=function(){varself=this;self.whatstuff='reallyawesome';}AwesomeObject.prototype.doStuff=function(){varself=this;console.log('idid'+self.whatstuff+'stuff');returnself;}varawesome=newAwesomeObject();//returnsanewAwesomeObjectawesome.doStuff();//prints'ididreallyawesomestu