Skip to content

Instantly share code, notes, and snippets.

@novogrammer
Last active May 14, 2021 11:17
Show Gist options
  • Save novogrammer/b33c249430adb87b771a9eb1f60878f2 to your computer and use it in GitHub Desktop.
Save novogrammer/b33c249430adb87b771a9eb1f60878f2 to your computer and use it in GitHub Desktop.
Pythonのrangeっぽいやつ
function range(start, stop) {
if (stop == null) {
return range(0, start);
}
if (stop < start) {
throw new Error("stop < start");
}
return [...Array(stop - start).keys()].map((e) => e + start);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment