我一直在阅读一堆react代码,我看到这样的东西,我不明白:
handleChange = field => e => {
e.preventDefault();
/// Do something here
}
Run Code Online (Sandbox Code Playgroud) 我curry在JavaScript中编写了一个简单的函数,可以在大多数情况下正常工作
const add = curry((a, b, c) => a + b + c);
const add2 = add(2);
const add5 = add2(3);
console.log(add5(5));Run Code Online (Sandbox Code Playgroud)
<script>
const curried = Symbol("curried");
Object.defineProperty(curry, curried, { value: true });
function curry(functor, ...initArgs) {
if (arguments.length === 0) return curry;
if (typeof functor !== "function") {
const value = JSON.stringify(functor);
throw new TypeError(`${value} is not a function`);
}
if (functor[curried] || initArgs.length >= functor.length)
return functor(...initArgs);
const result = (...restArgs) => curry(functor, ...initArgs, ...restArgs);
return …Run Code Online (Sandbox Code Playgroud)javascript haskell lambda-calculus currying partial-application