Skip to content

Instantly share code, notes, and snippets.

@yuanchuan
Created March 18, 2011 01:10
Show Gist options
  • Save yuanchuan/875460 to your computer and use it in GitHub Desktop.
Save yuanchuan/875460 to your computer and use it in GitHub Desktop.
range
function range(start, stop, step) {
var range = [];
stop || (stop = start || 0, start = 0);
step || (step = 1);
while ((step > 0 && start < stop) || (step < 0 && start > stop)) {
range.push(start);
start += step;
}
return range;
};
@yuanchuan
Copy link
Author

much shorter now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment