0

I'm trying to call login function defined in prototype but the function make the call (refresh) is also in the prototype.

function Checker() {
        var self = this;
        self.refresh();
        window.setInterval(function(){self.refresh()}, 1000);

}
Checker.prototype = {

        refresh: function() {
             if(some condition){
                 login(); // this won't work, neither self.login();
             }
        },
        login: function() {

        }
};

How do I call login function within refresh function?

0

2 Answers 2

3

From a prototype method, the instance is set to this. So this.login() is what you want.

Sign up to request clarification or add additional context in comments.

Comments

1

That's simple: Use this.login()

Comments

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.