0

my code is:

PRELOADER_COUNTER =  0;
class Preloader { 
    constructor(timeout=15000) {
        PRELOADER_COUNTER++;
        this.counter = PRELOADER_COUNTER;
        this.timeout = timeout;
    } 

    hide() {
        if ( this.counter === PRELOADER_COUNTER ){
            app.preloader.hide();
        }   
    }
    show() { 
        app.preloader.show();
        setTimeout(
            function(){
                this.hide(this.counter);
            }, this.timeout
        );
    }
} 

when i run in console:

var d = new Preloader(1000);
d.show();

i get this error: Uncaught TypeError: this.hide is not a function

what am i doing wrong?

91DarioDev
  • 1,612
  • 1
  • 14
  • 31

0 Answers0