Javascript Number downto(t, cb)
Number.prototype.downto = function (t, cb) { var i = this;/*from ww w. j av a 2 s . c om*/ if(t > this) { return +this; } while (i >= t) { cb(i--); } return +this; };
// 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 ww w . j a v a 2 s. c o m if(t > this) return +this; while (i >= t) { cb(i--); } return +this; };