Last active
June 4, 2018 08:50
-
-
Save nathan-lapinski/fed715bcebbe2d9aed5b034cb6366f98 to your computer and use it in GitHub Desktop.
Simple implementation of array.prototype.map
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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