Created
May 27, 2014 01:20
-
-
Save st98/a44ba6216ee9dc2efc2d to your computer and use it in GitHub Desktop.
ちょっと曲芸な感じの Number#times。リソースの無駄遣い。
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
Number.prototype.times = function (fn) { | |
Array.apply(null, { length: this }).forEach(fn); | |
}; | |
5..times(function (_, n) { | |
console.log(n); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment