Skip to content

Instantly share code, notes, and snippets.

@triacontane
Created January 18, 2016 17:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save triacontane/5cbf02c04abdfb7fd735 to your computer and use it in GitHub Desktop.
Save triacontane/5cbf02c04abdfb7fd735 to your computer and use it in GitHub Desktop.
指定した回数分処理を繰り返す
Number.prototype.times = function(handler) {
var i = 0; while(i < this) handler.call(this, i++);
};
Number(4).times(function(i) {
console.log(i)
}.bind(this));
// 0
// 1
// 2
// 3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment