getify / Functional-Light-JS

Pragmatic, balanced FP in JavaScript. @FLJSBook on twitter.
http://FLJSBook.com
Other
16.6k stars 1.96k forks source link

Why here need IIFE,thanks a lot #133

Closed DaZhaoLis closed 6 years ago

DaZhaoLis commented 6 years ago

function curry(fn,arity = fn.length) { // Q: why need IIFE ? return (function nextCurried(prevArgs){ return function curried(nextArg){ var args = [ ...prevArgs, nextArg ]; if (args.length >= arity) { return fn( ...args ); } else { return nextCurried( args ); } }; })( [] ); }