Skip to content

Instantly share code, notes, and snippets.

@rvbhute
Created January 17, 2018 14:17
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 rvbhute/dd857b4fb6769330ac80c4defa6cae08 to your computer and use it in GitHub Desktop.
Save rvbhute/dd857b4fb6769330ac80c4defa6cae08 to your computer and use it in GitHub Desktop.
Array.prototype.cmap = function(operation) {
var output = [];
for (var i = 0; i < this.length; i++) {
output[i] = operation(this[i]);
}
return output;
}
var addTwo = function (a) {
return a + 2;
}
var c = [1, 2, 3];
d = c.cmap(addTwo);
console.log(d);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment