Say you have an array-like Javascript ES6 Iterable that you know in advance will be finite in length, what\'s the best way to convert that to a Javascript Array?
The
You could also do:
let arr = [];
for (let elem of gen(...)){
arr.push(elem);
}
Or "the hard way" using ES5 + generator function (Fiddle works in current Firefox):
var squares = function*(n){
for (var i=0; i
Both are approaches are certainly not recommendable however and are merely a proof-of-concept.