1

I'm kind of a noobie in javascript, and when i try to use prototypes to extend my object, i get the following error code :

Object function ProcessManager() {...} has no method 'startBrowsing'

Here is my code. I execute this 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();

1 Answer 1

5

In your code sample, you're calling startBrowsing like it's a static method on your constructor function ProcessManager.

Methods added to the prototype of a constructor function are available as methods on instances. You should be calling startBrowsing on your instance of ProcessManager:

var processManager = new ProcessManager();
processManager.startBrowsing();
Sign up to request clarification or add additional context in comments.

1 Comment

You're right ! What an awful mistake i made. Thanks

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.