Why does the method gain another object?

0

Follow the script.

var indice = 0;
class Numeros {
    constructor() {
        this.indice = 0;
        this.exibir();
    }

    exibir() {
        var quadro = document.getElementsByClassName("quadro");
        document.write(this);
        indice++;
        setTimeout(this.exibir, 5000);

    }
}

numero = new Numeros();

In the first call this belongs to the Object object but when I call it with a certain time in milliseconds it happens to be an object window why does it happen?, and how would I do it to call a method within the method itself recursive way using the "SetTimeout" method?

What is the definition for this, would it be like a self in python that represents the object within the class?

    
asked by anonymous 10.06.2018 / 18:11

0 answers