Skip to content

Instantly share code, notes, and snippets.

@anthonywoodard
Created December 14, 2012 21:04
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 anthonywoodard/4288673 to your computer and use it in GitHub Desktop.
Save anthonywoodard/4288673 to your computer and use it in GitHub Desktop.
JavaScript Array Map Function
Array.prototype.map = function (fn) {
var l = this.length;
var a = [];
for (var i = 0; i < l; i++) {
a.push(fn(this[i]));
}
return a;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment