Return to Snippet

Revision: 19793
at October 30, 2009 18:27 by peta


Initial Code
Number.prototype.times = function(fn) {
	var i = (this > 0) ? this : 0;
	while (i--) {
		fn();
	}
}

Initial URL

                                

Initial Description
The Number objects value determines how often the supplied function is repeated. 
Inspired by ROR & Python.
"Pollutes" Number's prototype.

Initial Title
JS: Savvy looping on a Number

Initial Tags
javascript, js, number, python

Initial Language
JavaScript