Created
October 3, 2015 07:21
-
-
Save robbinhan/7aa113906b0ed988a3c8 to your computer and use it in GitHub Desktop.
柯里化函数接口
This file contains hidden or 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
var multiple = function(a){ | |
return function(b){ | |
return +b*a + '' | |
} | |
} | |
var plus = function(a){ | |
return function(b){ | |
return (+b)+a + '' | |
} | |
} | |
var concatArray = function(chars, stylishChar){ | |
return chars.map(stylishChar) | |
.reduce(function(a,b){ | |
return a.concat(b) | |
}); | |
} | |
console.log(concatArray(['1','2','3'], multiple(2))) | |
console.log(concatArray(['1','2','3'], plus(2))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment