Skip to content

Instantly share code, notes, and snippets.

@jonathanconway
Created December 10, 2010 04:37
Show Gist options
  • Save jonathanconway/735792 to your computer and use it in GitHub Desktop.
Save jonathanconway/735792 to your computer and use it in GitHub Desktop.
The times() method - a more pleasant way to do for-loops in Javascript
Number.prototype.times = function(fn) { for (var i = 0; i < this; i++) { fn(i); } }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment