Nodejs Array Next next()

Here you can find the source of next()

Method Source Code

Array.prototype.next = function() {
  var i = this.__i || 0;
  if(i >= this.length - 1) {
    return {//from  ww  w .jav a  2 s.  co  m
      done: true
    };
  }
  else {
    i++;
    return {
      done: i >= this.length - 1,
      value: this[i - 1]
    }
  }
};

Related

  1. next()
    Array.prototype.next = function() {
        return this[++this.current];
    };
    Array.prototype.previous = function() {
        return this[--this.current];
    };
    Array.prototype.current = 0;
    
  2. next()
    Array.prototype.next = function() {
      if (!((this.index + 1) in this)) return false;
        return this[++this.index];
    };
    
  3. next()
    Array.prototype.next = function() {
      var current = this.shift();
      this.push(current);
      return current;
    
  4. next(index)
    Array.prototype.next = function(index) {
        if (index === this.length - 1) {
            return this[0];
        } else {
            return this[index + 1];