Skip to content

Instantly share code, notes, and snippets.

@st98
Created June 5, 2014 05:13
Show Gist options
  • Save st98/ee2eb080ff9b3a38c3d0 to your computer and use it in GitHub Desktop.
Save st98/ee2eb080ff9b3a38c3d0 to your computer and use it in GitHub Desktop.
Number#step (Ruby の Numeric#step の劣化版)。
Number.prototype.step = function (limit, step, callback) {
var n = Number(this);
if (typeof step === 'function') {
callback = step;
step = 1;
}
while (n <= limit) {
callback(n);
n += step;
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment