Skip to content

Instantly share code, notes, and snippets.

@vinniefranco
Created August 24, 2011 00:01
Show Gist options
  • Save vinniefranco/1166957 to your computer and use it in GitHub Desktop.
Save vinniefranco/1166957 to your computer and use it in GitHub Desktop.
if (Array.prototype.map === undefined) {
Array.prototype.map = function(callback) {
var len = this.length;
if (typeof callback != "function") {
throw new TypeError();
}
var mapped = [len],
o = arguments[1];
for (var i = 0; i < len; i++) {
if (i in this) {
mapped[i] = callback.call(o, this[i], i, this);
}
}
return mapped;
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment