code: function iterateElements(array) {
    var index = 0;
    var rv = {};
    rv[Symbol.iterator] = {
        next() {
          if (index < array.length)
            return {value: array[index++], done: false};
          return {done: true};
        }
      }
    }
docs: Example 1. Writing an iterator over an array