/ Published in: JavaScript
The Number objects value determines how often the supplied function is repeated.
Inspired by ROR & Python.
"Pollutes" Number's prototype.
Inspired by ROR & Python.
"Pollutes" Number's prototype.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
Number.prototype.times = function(fn) { var i = (this > 0) ? this : 0; while (i--) { fn(); } }