Here you can find the source of downto(t, cb)
// Ruby = 15.downto(10) { |i| puts i } // JS = (15).downto(10, function(i){console.log(i);}) Number.prototype.downto = function(t, cb) { var i = this;/*from w w w.j av a 2s . c o m*/ if(t > this) return +this; while (i >= t) { cb(i--); } return +this; };
Number.prototype.upto = function (up, iterator) { for (var i = this.valueOf(); i <= up; i++) { iterator(i); return this.valueOf(); };
Number.prototype.upto = function (from) { var a = []; var to = this.valueOf(); var i = to - 1; while (i++ < from) { a.push(i); return a; }; ...
Number.prototype.upto = function (t, cb) { var i = this; if(t < this) { return +this; while (i <= t) { cb(i++); return +this; ...
Number.prototype.upto = function(t, cb) { var i = this; if(t < this) return +this; while (i <= t) { cb(i++); } return +this; };
Number.prototype.downto = function (t, cb) { var i = this; if(t > this) { return +this; while (i >= t) { cb(i--); return +this; ...
Number.prototype.downto = function (to) { var a = []; var from = this.valueOf(); var i = from + 1; while (i-- > to) { a.push(i); return a; }; ...