Skip to content

Instantly share code, notes, and snippets.

@pyrtsa
Created March 18, 2013 08:27
Show Gist options
  • Save pyrtsa/5185747 to your computer and use it in GitHub Desktop.
Save pyrtsa/5185747 to your computer and use it in GitHub Desktop.
function range(/* [begin,] end[, step] */) {
var begin = arguments.length > 1 ? arguments[0] : 0,
end = arguments.length > 1 ? arguments[1] : arguments[0],
step = arguments[2] || 1,
n = Math.max(0, Math.ceil((end - begin) / step))
return Array.apply(null, Array(n)).map(function (_, i) {
return begin + step * i
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment