codice:
this.step = function () {
var self = this;
// fai qualcosa
this.timer = setTimeout(function(){self.step()}, 1000);
}
il self come qualunque nome a scope locale può essere usato senza alcunissimo problema.
var window = 123;
var setInterval = 123;
var setTimeout = 123;
var document = 123;
ovvio che se nello scope devi usare window, setTimeout, documento o altro ti ritroveresti la top-level o globale che sia sovrascritta.
P.S. nel tuo caso preferirei setInterval
codice:
function my_animation() {
...
this.step = function () { // il this andrà
// fai qualcosa
}
...
this.start = function () {
var self = this;
this.stop();
this.timer = setInterval(function(){self.step()}, 2000);
}
...
this.stop = function () {
if (this.timer) {
clearInterval(this.timer);
this.timer = 0;
};
}
}