Nodejs Array Iterator __iterator__(flag)

Here you can find the source of __iterator__(flag)

Method Source Code

/*//from  ww w .j  a  v  a  2  s  .c o  m
 * JavaScript Array iterator
 * Requires JavaScript 1.7+
 *
 * 2010-03-11
 * 
 * By Eli Grey, http://eligrey.com
 *
 * Public Domain.
 * NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
 */

"use strict";

Array.prototype.__iterator__ = function (flag) {
   var len = this.length,
   item = 0;
   
   for (; item < len; i++) {
      yield flag ? item : this[item];
   }
};

Related

  1. __iterator__(isKeys)
    Array.prototype.__iterator__ = function(isKeys) {
      for( let i = 0, l = this.length; i<l; ++i )
        yield isKeys ? i : this[i];
    };