Here you can find the source of timesDo(callback)
/**//from www . j a v a2 s .co m * Kind of like ruby's 3.times do .. end method * usage: (3).timesDo(function() {} ); * * @param callback {function} to be called however many times */ Number.prototype.timesDo = function (callback) { if (callback) { for (var i = 0; i < this; i++) { callback.call(); } } };
Number.prototype.times = function(callback) { var i; if(typeof callback === 'undefined') { var array = []; for(i = 0; i < this; i++) array.push(i); return array; } else if(typeof callback === 'function') { for(i = 0; i < this; i++) callback(i); } else { ...
Number.prototype.times = function (cb) { var i = -1; while (++i < this) { cb(i); return +this; };
Number.prototype.times = function(cb) { var i = -1; while (++i < this) { cb(i); } return +this; };
Number.prototype.times = function(cb) { for (var i = 0; i < this; i++) cb(i); };
Number.prototype.times = function(object){ var l = []; this.timesRepeat(function(){l.push(object)}); return l;