Skip to content

Instantly share code, notes, and snippets.

@Alamin02
Created June 29, 2020 01:59
Show Gist options
  • Save Alamin02/450691c59541e71e897d0b77cba27e81 to your computer and use it in GitHub Desktop.
Save Alamin02/450691c59541e71e897d0b77cba27e81 to your computer and use it in GitHub Desktop.
function* indexMaker() {
var index = 0;
while (true)
yield index++;
}
const indexGenerator = indexMaker();
console.log(indexGenerator.next().value); // 0
console.log(indexGenerator.next().value); // 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment