Skip to content

Instantly share code, notes, and snippets.

@marcingolenia
Created March 11, 2026 06:22
Show Gist options
  • Select an option

  • Save marcingolenia/a38a7649faa3407beba625b2b0115848 to your computer and use it in GitHub Desktop.

Select an option

Save marcingolenia/a38a7649faa3407beba625b2b0115848 to your computer and use it in GitHub Desktop.
JS number array Generator
Number.prototype[Symbol.iterator] = function* () {
for (let i=0; i < this; i++) {
yield i;
}
}
//and then:
[...1000]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment