var MyInterval = function () { this.timer = ""; }; MyInterval.prototype.start = function(callback, times) { this.timer = setInterval(function() { callback(); }, times); } MyInterval.prototype.stop = function() { clearInterval(this.timer); } var myInterval = new MyInterval();