Created
March 18, 2011 01:10
-
-
Save yuanchuan/875460 to your computer and use it in GitHub Desktop.
range
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
much shorter now