Skip to content

Instantly share code, notes, and snippets.

@gfx
Created June 1, 2020 05:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gfx/5dae841a13d98c0aee6fbdf7b528eccd to your computer and use it in GitHub Desktop.
Save gfx/5dae841a13d98c0aee6fbdf7b528eccd to your computer and use it in GitHub Desktop.
function* iterateParams() {
for (const x of ["a", "b", "c"]) {
for (const i of [1, 2, 3]) {
yield { x, i };
}
}
}
for (const p of iterateParams()) {
console.log(p);
}
// results:
// { x: 'a', i: 1 }
// { x: 'a', i: 2 }
// { x: 'a', i: 3 }
// { x: 'b', i: 1 }
// { x: 'b', i: 2 }
// { x: 'b', i: 3 }
// { x: 'c', i: 1 }
// { x: 'c', i: 2 }
// { x: 'c', i: 3 }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment