javascript - Object has no method when using prototype -


i'm kind of noobie in javascript, , when try use prototypes extend object, following error code :

object function processmanager() {...} has no method 'startbrowsing' 

here code. execute code in nodejs.

the code

function processmanager(){     this.browser = new browser();      this.salepagestovisit = [];     this.salepagescurrent = [];     this.salepagesdone = [];      this.categorypagestovisit = [];     this.categorypagescurrent = [];     this.categorypagesdone = [];      this.listpagestovisit = [];     this.listpagescurrent = [];     this.listpagesdone = [];  }  processmanager.prototype.startbrowsing = function () {     winston.log('verbose', 'starting scrapping bazarchic');  }   var processmanager = new processmanager(); processmanager.startbrowsing(); 

in code sample, you're calling startbrowsing it's static method on constructor function processmanager.

methods added prototype of constructor function available methods on instances. should calling startbrowsing on instance of processmanager:

var processmanager = new processmanager(); processmanager.startbrowsing(); 

Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -