Created
October 29, 2016 02:06
-
-
Save atg/77f2e3187da54a515a067bb148549a56 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function () { | |
var array1, array2, array3, array4, gen, y, x; | |
array1 = [50, 30, 70, 20]; | |
var obj = { | |
idx: 0, | |
next: function() { | |
if (obj.idx >= array1.length) { | |
return { done: true }; | |
} | |
else { | |
var i = obj.idx++; | |
return { done: false, value: array1[i] }; | |
} | |
}, | |
}; | |
var gen = () => ({ | |
[Symbol.iterator]: () => obj, | |
}); | |
array2 = []; | |
array3 = []; | |
array4 = []; | |
y = gen(); | |
for (x of y) { | |
array2.push(x); | |
if (x === 30) { | |
break; | |
} | |
} | |
for (x of y) { | |
array3.push(x); | |
} | |
for (x of y) { | |
array4.push(x); | |
} | |
console.log(array2, [50, 30]); | |
console.log(array3, [70, 20]); | |
return console.log(array4, []); | |
})() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
s=k log w