Last active
September 22, 2016 19:02
-
-
Save layonthebeech/18d170f8024122eed5f37528b0c21898 to your computer and use it in GitHub Desktop.
Add a function "pipe" to the function prototype
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
Function.prototype.pipe = function(fun) { | |
return function(param) { | |
return fun(this(param)); | |
}.bind(this); //The bind() method creates a new function that, when called, has its this keyword | |
}; //set to the provided value, with a given sequence of arguments preceding any provided | |
//when the new function is called. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment