1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
| var something = (function(array){ var arr = array var nextVal; var i = 0;
return { [Symbol.iterator]:function(){ return this; },
next:function(){ var done = false; if(i < arr.length){ nextVal = array[i]; }else{ done = true; } i++ return {done:done, value:nextVal} } } })([10,50,99,-1]) for(let j of something){ console.log(j) }
|