JavaScript anonymous function as generator
This code produces what I want, which is a TypedArray containing [12, 34, 56]:
function * f() {
for (c of [12, 34, 56]) {
yield c;
}
};
t = new Uint8Array(f());
I expected this to do the same thing, but it just creates an empty array:
t2 = new Uint8Array(function *() {
for (c of [12, 34, 56]) {
yield c;
}
})
What am I doing wrong?