Last active
February 19, 2021 06:47
-
-
Save nanggo/3568ec7fe12d76bfbf9a3c037dcb0723 to your computer and use it in GitHub Desktop.
compose 구현
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 compose() { | |
const funcArray = Array.prototype.slice.call(arguments); | |
return funcArray.reduce( | |
(prevFunc, nextFunc) => | |
() => { | |
const args = Array.prototype.slice.call(arguments); | |
return nextFunc(prevFunc.apply(null, args)); | |
} | |
) | |
} | |
function comp() { | |
const funcArr = Array.prototype.slice.call(arguments); | |
return funcArr.reduce( | |
function(prevFunc, nextFunc) { | |
return function() { | |
const args = Array.prototype.slice.call(arguments); | |
return nextFunc(prevFunc.apply(null, args)); | |
} | |
} | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment