Javascript Array next()

Description

Javascript Array next()


Array.prototype.next = function() {
    return this[++this.current];
};

Javascript Array next()

Array.prototype.next = function() {
  var i = this.__i || 0;
  if(i >= this.length - 1) {
    return {/* w w  w  .j  a v a  2s  .c  om*/
      done: true
    };
  }
  else {
    i++;
    return {
      done: i >= this.length - 1,
      value: this[i - 1]
    }
  }
};



PreviousNext

Related