Last active
May 20, 2016 22:15
-
-
Save daronwolff/e0661c1eff049ec1bc50b0b10365e869 to your computer and use it in GitHub Desktop.
Write a DEmethodize, a function that converts a method to a binary function Example demethodize(Number.prototype.add)(5)(6) // 11
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 demethodize(func){ | |
return function(that,y){ | |
return func.call(that,y); | |
} | |
} | |
var add = (function(a) { | |
return function(b) { | |
return a + b; | |
} | |
}); | |
demethodize(Number.prototype.add)(3)(3) // 6 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment