jstherightway / js-the-right-way

An easy-to-read, quick reference for JS best practices, accepted coding standards, and links around the Web
http://jstherightway.org
Other
8.73k stars 933 forks source link

Currying #300

Open fabiante opened 7 years ago

fabiante commented 7 years ago

Hi guys,

I've got a suggestion for the js pattern section:

Yesterday I learned about currying. Maybe this could be usefull to be included. I included a list of sources that might be interesting:

https://www.sitepoint.com/currying-in-functional-javascript/ https://www.youtube.com/watch?v=iZLP4qOwY8I https://medium.com/@kbrainwave/currying-in-javascript-ce6da2d324fe

Cheers Really love your website, helps me a lot

allanesquina commented 7 years ago

Hey @fabitee, sorry the delay. Yea it could be very useful for sure. Let me know if you want to put that content by your self so that you can become a contributor. Thanks and welcome! :+1:

fabiante commented 7 years ago

@allanesquina I'd love to contribute but since I just got into the topic I don't think I'm overly qualified to find the perfect resources for this topic. Thing is, I found two ways people tend to curry stuff:

  1. Breaking down a function with multiple arguments into several functions with one argument each. A simple JSFiddle example.
  2. Object methods return the object itself so the functions can be chained together. JSFiddle right here.

I am unsure if version 2 really is currying or something else.