title: JavaScript curry: what are the practical applications?
body: <p>I don’t think I’ve grokked currying yet. I understand what it does, and how to do it. I just can’t think of a situation I would use it.</p>
  
  <p>Where are you using currying in JavaScript (or where are the main libraries using it)? DOM manipulation or general application development examples welcome.</p>
  
  <p><a href="https://stackoverflow.com/questions/113780/javascript-curry-what-are-the-practical-applications#113799">One of the answers</a> mentions animation. Functions like <code>slideUp</code>, <code>fadeIn</code> take an element as an arguments and are normally a curried function returning the high order function with the default “animation function” built-in. Why is that better than just applying the higher-up function with some defaults?</p>
  
  <p>Are there any drawbacks to using it?</p>
  
  <p>As requested here are some good resources on JavaScript currying:</p>
  
  <ul>
  <li><a href="http://www.dustindiaz.com/javascript-curry/" rel="noreferrer">http://www.dustindiaz.com/javascript-curry/</a></li>
  <li>Crockford, Douglas (2008) <em>JavaScript: The Good Parts</em></li>
  <li><a href="http://www.crockford.com/javascript/www_svendtofte_com/code/curried_javascript/index.html" rel="noreferrer">http://www.svendtofte.com/code/curried_javascript/</a>
  (Takes a detour into ML so skip the whole section from “A crash course in ML” and start again at “How to write curried JavaScript”)</li>
  <li><a href="http://web.archive.org/web/20111217011630/http://blog.morrisjohns.com:80/javascript_closures_for_dummies" rel="noreferrer">http://web.archive.org/web/20111217011630/http://blog.morrisjohns.com:80/javascript_closures_for_dummies</a></li>
  <li><a href="https://stackoverflow.com/questions/111102/how-does-a-javascript-closure-work">How do JavaScript closures work?</a></li>
  <li><strong><a href="http://ejohn.org/blog/partial-functions-in-javascript/" rel="noreferrer">http://ejohn.org/blog/partial-functions-in-javascript</a> (Mr. Resig on the money as per usual)</strong></li>
  <li><a href="http://benalman.com/news/2010/09/partial-application-in-javascript/" rel="noreferrer">http://benalman.com/news/2010/09/partial-application-in-javascript/</a></li>
  </ul>
  
  <p>I’ll add more as they crop up in the comments.</p>
  
  <hr>
  
  <p>So, according to the answers, currying and partial application in general are convenience techniques.</p>
  
  <p>If you are frequently “refining” a high-level function by calling it with same configuration, you can curry (or use Resig’s partial) the higher-level function to create simple, concise helper methods.</p>