demo/generators.js
function iterateElements(array) {
  return {
    __iterator__: function() {
      var index = 0;
      var current;
      return {
        get current() {
          return current;
        },
        moveNext: function() {
          if (index < array.length) {
            current = array[index++];
            return true;
          }
          return false;
        }
      };
    }
  };
}
function iterateElements(array) {
  return {
    __iterator__: function() {
      var index = 0;
      var current;
      return {
        get current() {
          return current;
        },
        moveNext: function() {
          if (index < array.length) {
            current = array[index++];
            return true;
          }
          return false;
        }
      };
    }
  };
}
function iterateElements ( array ) { return { __iterator__ : function ( ) { var index = 0 ; var current ; return { get current ( ) { return current ; } , moveNext : function ( ) { if ( index < array . length ) { current = array [ index ++ ] ; return true ; } return false ; } } ; } } ; }
Example 1. Writing an iterator over an array
Example 1 . Writing an iterator over an array