Skip to content

Instantly share code, notes, and snippets.

@jonathanconway
Created December 10, 2010 04:37
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 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