Nodejs Number Iterate downto(to)

Here you can find the source of downto(to)

Method Source Code

Number.prototype.downto = function (to) {
  var a = [];/*www . j  a  v a 2  s . co m*/
  var from = this.valueOf();
  var i = from + 1;
  while (i-- > to) {
    a.push(i);
  }
  return a;
};

Related

  1. upto(from)
    Number.prototype.upto = function (from) {
      var a = [];
      var to = this.valueOf();
      var i = to - 1;
      while (i++ < from) {
        a.push(i);
      return a;
    };
    ...
    
  2. upto(t, cb)
    Number.prototype.upto = function (t, cb) {
      var i = this;
      if(t < this) {
        return +this;
      while (i <= t) {
        cb(i++);
      return +this;
    ...
    
  3. upto(t, cb)
    Number.prototype.upto = function(t, cb) {
      var i = this;
      if(t < this) return +this;
      while (i <= t) { cb(i++); }
      return +this;
    };
    
  4. downto(t, cb)
    Number.prototype.downto = function (t, cb) {
      var i = this;
      if(t > this) {
        return +this;
      while (i >= t) {
        cb(i--);
      return +this;
    ...
    
  5. downto(t, cb)
    Number.prototype.downto = function(t, cb) {
      var i = this;
      if(t > this) return +this;
      while (i >= t) { cb(i--); }
      return +this;
    };