Skip to content

Instantly share code, notes, and snippets.

@nathan-lapinski
Last active June 4, 2018 08:50
Show Gist options
  • Save nathan-lapinski/fed715bcebbe2d9aed5b034cb6366f98 to your computer and use it in GitHub Desktop.
Save nathan-lapinski/fed715bcebbe2d9aed5b034cb6366f98 to your computer and use it in GitHub Desktop.
Simple implementation of array.prototype.map
// overriding properties on Array.prototype is a bad idea. This is given for educational purposes only :D
Array.prototype.map = function(projectionFn) {
let retVal = [];
for (let i = 0; i < this.length; i++) {
retVal.push(projectionFn(this[i]));
}
return retVal;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment