<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Yazeed Bzadough</title>
    <description>The latest articles on Forem by Yazeed Bzadough (@yazeedb).</description>
    <link>https://forem.com/yazeedb</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F170232%2F8bd8c637-b4e3-4056-a21d-d367a0f18e8d.jpeg</url>
      <title>Forem: Yazeed Bzadough</title>
      <link>https://forem.com/yazeedb</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/yazeedb"/>
    <language>en</language>
    <item>
      <title>How to 10x Your Productivity by Creating a Process</title>
      <dc:creator>Yazeed Bzadough</dc:creator>
      <pubDate>Wed, 17 Jul 2019 23:55:30 +0000</pubDate>
      <link>https://forem.com/yazeedb/how-to-10x-your-productivity-by-creating-a-process-4k80</link>
      <guid>https://forem.com/yazeedb/how-to-10x-your-productivity-by-creating-a-process-4k80</guid>
      <description>&lt;p&gt;&lt;em&gt;Originally posted on &lt;a href="https://yazeedb.com" rel="noopener noreferrer"&gt;&lt;/a&gt;&lt;a href="https://yazeedb.com" rel="noopener noreferrer"&gt;https://yazeedb.com&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Thank You
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://yazeedb.com/posts/how-to-kill-procrastination" rel="noopener noreferrer"&gt;My last article&lt;/a&gt; on killing procrastination did much better than I expected. It was reassuring to see others like myself fighting this uphill battle, and heartwarming to hear that you all enjoyed my humble piece! Thank you ❤️&lt;/p&gt;

&lt;p&gt;In an effort to keep the momentum going, let’s talk about creating processes.&lt;/p&gt;

&lt;h2&gt;
  
  
  I’m Going Somewhere!
&lt;/h2&gt;

&lt;p&gt;You’re scrolling through your phone and YouTube recommends yet another motivational video because it knows how much you love them, &lt;em&gt;&lt;strong&gt;How I Tripled my Net Worth&lt;/strong&gt;&lt;/em&gt; or whatever. You listen to soundbites of a dude claiming that deep breathing and not eating vegetables transformed him into a CEO.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fas64myz8v98rd8otsjug.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fas64myz8v98rd8otsjug.jpg"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Man triples his net worth by eschewing broccoli&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Like all the others it’s loud and bold enough to stir a familiar feeling within you, and by the time the video ends, a sudden amp and feverish itch make it clear as day–you’ve been bitten by the Inspiration Bug again.&lt;/p&gt;

&lt;p&gt;What happens next? Just the usual...&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“I will become a web developer!”&lt;/p&gt;

&lt;p&gt;“I will start working out tomorrow!”&lt;/p&gt;

&lt;p&gt;“I will get a promotion!”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Your battle cries may vary, but your mileage won’t. &lt;strong&gt;You are still going nowhere&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fzdl4igb02zh7y9jrfs2p.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fzdl4igb02zh7y9jrfs2p.jpg"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fpi1mltb0cthph63a4qf3.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fpi1mltb0cthph63a4qf3.jpeg"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Care to Be More Specific?
&lt;/h2&gt;

&lt;p&gt;What does “I will become a web developer” even mean? How can we track progress on these nebulous phrases that you shout whenever inspiration strikes?&lt;/p&gt;

&lt;p&gt;I'm not saying don't have lofty goals. Be inspired. Get energized! But please use that energy to be more specific. Talking feels good, we’ve gone over this, but when you inevitably come back down from that inspirational high, what are your concrete actions going to be?&lt;/p&gt;

&lt;p&gt;Don’t just say, “I am going to learn web development” Do you know how gargantuan of a task that is?!&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;HTML, CSS, JavaScript&lt;/li&gt;
&lt;li&gt;Frameworks/Libraries&lt;/li&gt;
&lt;li&gt;Testing&lt;/li&gt;
&lt;li&gt;Accessibility&lt;/li&gt;
&lt;li&gt;Build tools&lt;/li&gt;
&lt;li&gt;HTTP&lt;/li&gt;
&lt;li&gt;SEO&lt;/li&gt;
&lt;li&gt;Animations&lt;/li&gt;
&lt;li&gt;REST APIs&lt;/li&gt;
&lt;li&gt;Templating engines&lt;/li&gt;
&lt;li&gt;State management&lt;/li&gt;
&lt;li&gt;Command line&lt;/li&gt;
&lt;li&gt;Fatigued yet?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fbqo7ine3z7sxrl8m6pil.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fbqo7ine3z7sxrl8m6pil.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;This is the JS ecosystem from 2016...&lt;em&gt;three years ago!&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I was suffering from this around 2013, before JavaScript &lt;em&gt;really&lt;/em&gt; detonated a few years later. If we’re going by that definition then even with nearly 5 years experience, I still haven’t “learned” web development and I never will.&lt;/p&gt;

&lt;p&gt;Every endeavor has a ton of paths, and most of us waste precious time considering all possible paths instead of just committing to one and flourishing.&lt;/p&gt;

&lt;p&gt;You're going to end up unmotivated again, because a specific target wasn't set.&lt;/p&gt;

&lt;h2&gt;
  
  
  Tell Me What You Want
&lt;/h2&gt;

&lt;p&gt;You want to become a web developer, ok great.&lt;/p&gt;

&lt;p&gt;What kind? Why?&lt;/p&gt;

&lt;p&gt;Do you want a job? What kind of job? Do you want a business? What kind of business? &lt;strong&gt;Tell me exactly what you want!&lt;/strong&gt; Once we identify your target, we can prepare for the hunt.&lt;/p&gt;

&lt;p&gt;Here's an example of Batman guiding Joker through it.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F96ox8v9heot9vtun4tzz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F96ox8v9heot9vtun4tzz.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Joker&lt;/strong&gt;: Fine! I flipped a coin and think UIs are cool, let’s focus on Front-End development (for now). I want to become a &lt;em&gt;Front-End&lt;/em&gt; web developer.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Batman&lt;/strong&gt;: Good, where?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fn4nkpqwe30kpuymmisqa.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fn4nkpqwe30kpuymmisqa.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Joker&lt;/strong&gt;: I have kids, so no more than 1 hour from the house. A remote position would be ideal.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Feelog0spoir0s5hipcz3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Feelog0spoir0s5hipcz3.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Batman&lt;/strong&gt;: Here’s a job description based on countless Indeed.com postings.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  Job description
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Strong knowledge of HTML, CSS, JavaScript&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Knowledge of modern mobile/responsive design techniques&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Git/GitHub&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Excellent verbal and written communication&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Bonus points for React, Angular, Vue, Node.js&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fmjt5v56wqir6kdgktc7s.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fmjt5v56wqir6kdgktc7s.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Joker&lt;/strong&gt;: What’s the fastest way to succeed?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fzh2o2tls4i31bk1hkpgc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fzh2o2tls4i31bk1hkpgc.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Batman&lt;/strong&gt;: Turn yourself into this candidate. We’ll work towards that by creating a process.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Creating a Process
&lt;/h2&gt;

&lt;p&gt;This requires you to critically think about the goal. What steps must we take to progress?&lt;/p&gt;

&lt;p&gt;How about a project that incorporates the job description we just found? I always recommend beginners to make a clone of &lt;a href="http://todomvc.com/examples/vanillajs/" rel="noopener noreferrer"&gt;todomvc.com.&lt;/a&gt; For best results, conform as close to the job description as possible.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fcixvrnvq184avbtnvg9f.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fcixvrnvq184avbtnvg9f.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Use HTML, CSS, and JavaScript&lt;/li&gt;
&lt;li&gt;Make sure the app looks spectacular on all screen sizes&lt;/li&gt;
&lt;li&gt;Put it on GitHub&lt;/li&gt;
&lt;li&gt;Not everyone will agree here, but I say don't use a framework until you’re somewhat proficient in JavaScript. This means you can comfortably write basic apps without needing a framework and you understand how the pieces connect in a more complex app.&lt;/li&gt;
&lt;li&gt;Once you’re more advanced, feel free to redo this in React, Angular, Vue, etc.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Less Shopping, More Googling
&lt;/h2&gt;

&lt;p&gt;The important thing here is to pick a project. Don't buy another course or book until it gets done. &lt;strong&gt;You’ll learn everything by Googling the problems you encounter.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fy1y1ocxks5j0j1q6wast.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fy1y1ocxks5j0j1q6wast.jpg"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After that, pick a different or slightly harder version of the project, rinse and repeat. Do that a few times and you have a portfolio of apps you built from the ground up.&lt;/p&gt;

&lt;p&gt;There’s your process–congratulations, you’re now exactly like the candidate in that job description. Maybe even better, depending on the apps you completed.&lt;/p&gt;

&lt;h2&gt;
  
  
  This Works Everywhere
&lt;/h2&gt;

&lt;p&gt;I’m a huge fan of universal principles, and &lt;strong&gt;create a process&lt;/strong&gt; is one of them.&lt;/p&gt;

&lt;p&gt;Whatever you’re doing–programming, speaking, lifting, sports, chess, Chinese, you learn it through following a trusted process. Either pay someone (school, bootcamp, course, mentor) to create that process, or do it yourself.&lt;/p&gt;

&lt;p&gt;Bottom line is that process &lt;em&gt;must&lt;/em&gt; be created, otherwise you’ll keep getting inspired, making vague declarations of change, and remain the same.&lt;/p&gt;

&lt;p&gt;That’s momentum my friends. It’s wrecked me several times, and now I know some of you feel that pain too. It’ll push us right off the cliff unless we slam the brakes and turn the car around.&lt;/p&gt;

&lt;p&gt;But just remember next time, before you start going the other direction, use a map.&lt;/p&gt;

&lt;p&gt;Until next time!&lt;/p&gt;

&lt;p&gt;&lt;em&gt;For more content like this, check out &lt;a href="https://yazeedb.com" rel="noopener noreferrer"&gt;&lt;/a&gt;&lt;a href="https://yazeedb.com" rel="noopener noreferrer"&gt;https://yazeedb.com&lt;/a&gt;!&lt;/em&gt;&lt;/p&gt;

</description>
      <category>motivation</category>
      <category>javascript</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Deeply Understand Currying in 7 Minutes</title>
      <dc:creator>Yazeed Bzadough</dc:creator>
      <pubDate>Wed, 17 Jul 2019 23:41:20 +0000</pubDate>
      <link>https://forem.com/yazeedb/deeply-understand-currying-in-7-minutes-1ago</link>
      <guid>https://forem.com/yazeedb/deeply-understand-currying-in-7-minutes-1ago</guid>
      <description>&lt;p&gt;&lt;em&gt;Originally posted on &lt;a href="https://yazeedb.com" rel="noopener noreferrer"&gt;yazeedb.com&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Eric Elliott’s exceptional &lt;a href="https://medium.com/javascript-scene/the-rise-and-fall-and-rise-of-functional-programming-composable-software-c2d91b424c8c" rel="noopener noreferrer"&gt;Composing Software&lt;/a&gt; series is initially what got me excited about functional programming. It's a must-read.&lt;/p&gt;

&lt;p&gt;At one point in the series, he mentioned &lt;em&gt;currying&lt;/em&gt;. Both computer science and mathematics agree on the definition:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Currying turns multi-argument functions into unary (single argument) functions.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Curried functions take many arguments &lt;strong&gt;one at a time&lt;/strong&gt;. So if you have&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;greet&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;greeting&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;first&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;last&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;greeting&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;, &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;first&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;last&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nf"&gt;greet&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Hello&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Bruce&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Wayne&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Hello, Bruce Wayne&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Properly currying &lt;code&gt;greet&lt;/code&gt; gives you&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;curriedGreet&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;curry&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;greet&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="nf"&gt;curriedGreet&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Hello&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Bruce&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Wayne&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Hello, Bruce Wayne&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This 3-argument function has been turned into three unary functions. As you supply one parameter, a new function pops out expecting the next one.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F7np833ublebvdsj38rcv.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F7np833ublebvdsj38rcv.jpeg"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Properly?
&lt;/h2&gt;

&lt;p&gt;I say "properly currying" because some &lt;code&gt;curry&lt;/code&gt; functions are more flexible in their usage. Currying's great in theory, but invoking a function for each argument gets tiring in JavaScript.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://ramdajs.com/" rel="noopener noreferrer"&gt;Ramda's&lt;/a&gt; &lt;code&gt;curry&lt;/code&gt; function lets you invoke &lt;code&gt;curriedGreet&lt;/code&gt; like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// greet requires 3 params: (greeting, first, last)&lt;/span&gt;

&lt;span class="c1"&gt;// these all return a function looking for (first, last)&lt;/span&gt;
&lt;span class="nf"&gt;curriedGreet&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Hello&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nf"&gt;curriedGreet&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Hello&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)();&lt;/span&gt;
&lt;span class="nf"&gt;curriedGreet&lt;/span&gt;&lt;span class="p"&gt;()(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Hello&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)()();&lt;/span&gt;

&lt;span class="c1"&gt;// these all return a function looking for (last)&lt;/span&gt;
&lt;span class="nf"&gt;curriedGreet&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Hello&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Bruce&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nf"&gt;curriedGreet&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Hello&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Bruce&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nf"&gt;curriedGreet&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Hello&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)()(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Bruce&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)();&lt;/span&gt;

&lt;span class="c1"&gt;// these return a greeting, since all 3 params were honored&lt;/span&gt;
&lt;span class="nf"&gt;curriedGreet&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Hello&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Bruce&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Wayne&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nf"&gt;curriedGreet&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Hello&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Bruce&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Wayne&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nf"&gt;curriedGreet&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Hello&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Bruce&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)()()(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Wayne&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Notice you can choose to give multiple arguments in a single shot. This implementation's more useful while writing code.&lt;/p&gt;

&lt;p&gt;And as demonstrated above, you can invoke this function forever without parameters and it’ll always return a function that expects the remaining parameters.&lt;/p&gt;

&lt;h2&gt;
  
  
  How's This Possible?
&lt;/h2&gt;

&lt;p&gt;Mr. Elliot shared a &lt;code&gt;curry&lt;/code&gt; implementation much like Ramda's. Here’s the code, or as he aptly called it, a magic spell:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;curry&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;f&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;arr&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[])&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;(...&lt;/span&gt;&lt;span class="nx"&gt;args&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;
  &lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="nx"&gt;f&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="nf"&gt;f&lt;/span&gt;&lt;span class="p"&gt;(...&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;curry&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;f&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;)))([...&lt;/span&gt;&lt;span class="nx"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;...&lt;/span&gt;&lt;span class="nx"&gt;args&lt;/span&gt;&lt;span class="p"&gt;]);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Umm… 😐
&lt;/h2&gt;

&lt;p&gt;&lt;a href="/news/content/images/2019/07/that-code-is-hard-to-read-cmm.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="/news/content/images/2019/07/that-code-is-hard-to-read-cmm.jpeg" alt="that-code-is-hard-to-read-cmm"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Yeah, I know... It's incredibly concise, so let's refactor and appreciate it together.&lt;/p&gt;

&lt;h2&gt;
  
  
  This Version Works the Same
&lt;/h2&gt;

&lt;p&gt;I've also sprinkled &lt;code&gt;debugger&lt;/code&gt; statements to examine it in Chrome Developer Tools.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;curry&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;originalFunction&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;initialParams&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[])&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;debugger&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(...&lt;/span&gt;&lt;span class="nx"&gt;nextParams&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;debugger&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;curriedFunction&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;params&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;debugger&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

      &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;params&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="nx"&gt;originalFunction&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;originalFunction&lt;/span&gt;&lt;span class="p"&gt;(...&lt;/span&gt;&lt;span class="nx"&gt;params&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;

      &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;curry&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;originalFunction&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;params&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;};&lt;/span&gt;

    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;curriedFunction&lt;/span&gt;&lt;span class="p"&gt;([...&lt;/span&gt;&lt;span class="nx"&gt;initialParams&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;...&lt;/span&gt;&lt;span class="nx"&gt;nextParams&lt;/span&gt;&lt;span class="p"&gt;]);&lt;/span&gt;
  &lt;span class="p"&gt;};&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Open your &lt;a href="https://developers.google.com/web/tools/chrome-devtools/" rel="noopener noreferrer"&gt;Developer Tools&lt;/a&gt; and follow along!&lt;/p&gt;

&lt;h2&gt;
  
  
  Let's Do This!
&lt;/h2&gt;

&lt;p&gt;Paste &lt;code&gt;greet&lt;/code&gt; and &lt;code&gt;curry&lt;/code&gt; into your console. Then enter &lt;code&gt;curriedGreet = curry(greet)&lt;/code&gt; and begin the madness.&lt;/p&gt;

&lt;h3&gt;
  
  
  Pause on line 2
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1600%2F1%2A8_q3YkOu6fDzIEMY65lqUg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1600%2F1%2A8_q3YkOu6fDzIEMY65lqUg.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Inspecting our two params we see &lt;code&gt;originalFunction&lt;/code&gt; is &lt;code&gt;greet&lt;/code&gt; and &lt;code&gt;initialParams&lt;/code&gt; defaulted to an empty array because we didn’t supply it. Move to the next breakpoint and, oh wait… that’s it.&lt;/p&gt;

&lt;p&gt;Yep! &lt;code&gt;curry(greet)&lt;/code&gt; just returns a new function that expects 3 more parameters. Type &lt;code&gt;curriedGreet&lt;/code&gt; in the console to see what I’m talking about.&lt;/p&gt;

&lt;p&gt;When you’re done playing with that, let’s get a bit crazier and do&lt;br&gt;
&lt;code&gt;sayHello = curriedGreet('Hello')&lt;/code&gt;.&lt;/p&gt;
&lt;h3&gt;
  
  
  Pause on line 4
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1600%2F1%2AFXCJQi5Numlbis5d_bGsjw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1600%2F1%2AFXCJQi5Numlbis5d_bGsjw.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Before moving on, type &lt;code&gt;originalFunction&lt;/code&gt; and &lt;code&gt;initialParams&lt;/code&gt; in your console. Notice we can still access those 2 parameters even though we’re in a completely new function? That’s because functions returned from parent functions enjoy their parent’s scope.&lt;/p&gt;
&lt;h4&gt;
  
  
  Real-life inheritance
&lt;/h4&gt;

&lt;p&gt;After a parent function passes on, they leave their parameters for their kids to use. Kind of like inheritance in the real life sense.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;curry&lt;/code&gt; was initially given &lt;code&gt;originalFunction&lt;/code&gt; and &lt;code&gt;initialParams&lt;/code&gt; and then returned a “child” function. Those 2 variables weren’t &lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Memory_Management" rel="noopener noreferrer"&gt;disposed of&lt;/a&gt; yet because maybe that child needs them. If he doesn’t, &lt;em&gt;then&lt;/em&gt; that scope gets cleaned up because when no one references you, that’s when you truly die.&lt;/p&gt;
&lt;h3&gt;
  
  
  Ok, back to line 4…
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1600%2F1%2A_TFVnxtqgisi1i0q_K3dUQ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1600%2F1%2A_TFVnxtqgisi1i0q_K3dUQ.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Inspect &lt;code&gt;nextParams&lt;/code&gt; and see that it’s &lt;code&gt;['Hello']&lt;/code&gt;…an array? But I thought we said &lt;code&gt;curriedGreet(‘Hello’)&lt;/code&gt; , not &lt;code&gt;curriedGreet(['Hello'])&lt;/code&gt;!&lt;/p&gt;

&lt;p&gt;Correct: we invoked &lt;code&gt;curriedGreet&lt;/code&gt; with &lt;code&gt;'Hello'&lt;/code&gt;, but thanks to the &lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_operator#Rest_syntax_%28parameters%29" rel="noopener noreferrer"&gt;rest syntax&lt;/a&gt;, we’ve &lt;em&gt;turned&lt;/em&gt; &lt;code&gt;'Hello'&lt;/code&gt; into &lt;code&gt;['Hello']&lt;/code&gt;.&lt;/p&gt;
&lt;h3&gt;
  
  
  Y THO?!
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;curry&lt;/code&gt; is a general function that can be supplied 1, 10, or 10,000,000 parameters, so it needs a way to reference all of them. Using the rest syntax like that captures every single parameter in one array, making &lt;code&gt;curry&lt;/code&gt;'s job much easier.&lt;/p&gt;

&lt;p&gt;Let’s jump to the next &lt;code&gt;debugger&lt;/code&gt; statement.&lt;/p&gt;
&lt;h3&gt;
  
  
  Line 6 now, but hold on.
&lt;/h3&gt;

&lt;p&gt;You may have noticed that line 12 actually ran before the &lt;code&gt;debugger&lt;/code&gt; statement on line 6. If not, look closer. Our program defines a function called &lt;code&gt;curriedFunction&lt;/code&gt; on line 5, uses it on line 12, and &lt;em&gt;then&lt;/em&gt; we hit that &lt;code&gt;debugger&lt;/code&gt; statement on line 6. And what’s &lt;code&gt;curriedFunction&lt;/code&gt; invoked with?&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="p"&gt;[...&lt;/span&gt;&lt;span class="nx"&gt;initialParams&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;...&lt;/span&gt;&lt;span class="nx"&gt;nextParams&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Yuuuup. Look at &lt;code&gt;params&lt;/code&gt; on line 5 and you’ll see &lt;code&gt;['Hello']&lt;/code&gt;. Both &lt;code&gt;initialParams&lt;/code&gt; and &lt;code&gt;nextParams&lt;/code&gt; were arrays, so we flattened and combined them into a single array using the handy &lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_operator#Syntax" rel="noopener noreferrer"&gt;spread operator&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Here’s where the good stuff happens.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1600%2F1%2ApM31i2QVNxVUiqj9aZzVvg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1600%2F1%2ApM31i2QVNxVUiqj9aZzVvg.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Line 7 says “If &lt;code&gt;params&lt;/code&gt; and &lt;code&gt;originalFunction&lt;/code&gt; are the same length, call &lt;code&gt;greet&lt;/code&gt; with our params and we’re done.” Which reminds me…&lt;/p&gt;

&lt;h3&gt;
  
  
  JavaScript functions have lengths too
&lt;/h3&gt;

&lt;p&gt;This is how &lt;code&gt;curry&lt;/code&gt; does its magic! This is how it decides whether or not to ask for more parameters.&lt;/p&gt;

&lt;p&gt;In JavaScript, a function’s &lt;code&gt;.length&lt;/code&gt; property tells you &lt;em&gt;how many arguments it expects&lt;/em&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;greet&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// 3&lt;/span&gt;

&lt;span class="nx"&gt;iTakeOneParam&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{};&lt;/span&gt;
&lt;span class="nx"&gt;iTakeTwoParams&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{};&lt;/span&gt;

&lt;span class="nx"&gt;iTakeOneParam&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// 1&lt;/span&gt;
&lt;span class="nx"&gt;iTakeTwoParams&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// 2&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If our provided and expected parameters match, we’re good, just hand them off to the original function and finish the job!&lt;/p&gt;

&lt;h3&gt;
  
  
  That’s baller 🏀
&lt;/h3&gt;

&lt;p&gt;But in our case, the parameters and function length are &lt;em&gt;not&lt;/em&gt; the same. We only provided &lt;code&gt;‘Hello’&lt;/code&gt;, so &lt;code&gt;params.length&lt;/code&gt; is 1, and &lt;code&gt;originalFunction.length&lt;/code&gt; is 3 because &lt;code&gt;greet&lt;/code&gt; expects 3 parameters: &lt;code&gt;greeting, first, last&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  So what happens next?
&lt;/h3&gt;

&lt;p&gt;Well since that &lt;code&gt;if&lt;/code&gt; statement evaluates to &lt;code&gt;false&lt;/code&gt;, the code will skip to line 10 and re-invoke our master &lt;code&gt;curry&lt;/code&gt; function. It re-receives &lt;code&gt;greet&lt;/code&gt; and this time, &lt;code&gt;'Hello'&lt;/code&gt;, and begins the madness all over again.&lt;/p&gt;

&lt;p&gt;That’s &lt;a href="https://developer.mozilla.org/en-US/docs/Glossary/Recursion" rel="noopener noreferrer"&gt;recursion&lt;/a&gt;, my friends.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;curry&lt;/code&gt; is essentially an infinite loop of self-calling, parameter-hungry functions that won’t rest until their guest is full. Hospitality at its finest.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1600%2F1%2AAZKiupYSanV5iJSQWrtUwg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1600%2F1%2AAZKiupYSanV5iJSQWrtUwg.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Back at line 2
&lt;/h3&gt;

&lt;p&gt;Same parameters as before, except &lt;code&gt;initialParams&lt;/code&gt; is &lt;code&gt;['Hello']&lt;/code&gt; this time. Skip again to exit the cycle. Type our new variable into the console, &lt;code&gt;sayHello&lt;/code&gt;. It’s another function, still expecting more parameters, but we’re getting warmer…&lt;/p&gt;

&lt;p&gt;Let’s turn up the heat with &lt;code&gt;sayHelloToJohn = sayHello('John')&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;We’re inside line 4 again, and &lt;code&gt;nextParams&lt;/code&gt; is &lt;code&gt;['John']&lt;/code&gt;. Jump to the next debugger on line 6 and inspect &lt;code&gt;params&lt;/code&gt;: it’s &lt;code&gt;['Hello', 'John']&lt;/code&gt;! 🙀&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1600%2F1%2Apej6yZ-vGvA2T9LgIIc-vg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1600%2F1%2Apej6yZ-vGvA2T9LgIIc-vg.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Why, why, why?
&lt;/h3&gt;

&lt;p&gt;Because remember, line 12 says “Hey &lt;code&gt;curriedFunction&lt;/code&gt;, he gave me &lt;code&gt;'Hello'&lt;/code&gt; last time and &lt;code&gt;‘John’&lt;/code&gt; this time. Take them both in this array &lt;code&gt;[...initialParams, ...nextParams]&lt;/code&gt;.”&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1600%2F1%2ALjvk2BMLxIsbJ09idgStdg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1600%2F1%2ALjvk2BMLxIsbJ09idgStdg.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now &lt;code&gt;curriedFunction&lt;/code&gt; again compares the &lt;code&gt;length&lt;/code&gt; of these &lt;code&gt;params&lt;/code&gt; to &lt;code&gt;originalFunction&lt;/code&gt;, and since &lt;code&gt;2 &amp;lt; 3&lt;/code&gt; we move to line 10 and call &lt;code&gt;curry&lt;/code&gt; once again! And of course, we pass along &lt;code&gt;greet&lt;/code&gt; and our 2 params, &lt;code&gt;['Hello', 'John']&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1600%2F1%2AEYv9jdo2id8tynbTI5SXYQ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1600%2F1%2AEYv9jdo2id8tynbTI5SXYQ.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We’re so close, let’s finish this and get the full greeting back!&lt;/p&gt;

&lt;p&gt;&lt;code&gt;sayHelloToJohnDoe = sayHelloToJohn('Doe')&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;I think we know what happens next.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1600%2F1%2AtMJvls2j9eAjrCGykVN84g.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1600%2F1%2AtMJvls2j9eAjrCGykVN84g.png"&gt;&lt;/a&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1600%2F1%2ANHm1TMo8Tjk7jQVlGGa9zQ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1600%2F1%2ANHm1TMo8Tjk7jQVlGGa9zQ.png"&gt;&lt;/a&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1600%2F1%2AeTwjEYLKGCGJoqdP4Xe9hA.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1600%2F1%2AeTwjEYLKGCGJoqdP4Xe9hA.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The Deed Is Done
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;greet&lt;/code&gt; got his parameters, &lt;code&gt;curry&lt;/code&gt; stopped looping, and we’ve received our greeting: &lt;code&gt;Hello, John Doe&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Play around with this function some more. Try supplying multiple or no parameters in one shot, get as crazy as you want. See how many times &lt;code&gt;curry&lt;/code&gt; has to recurse before returning your expected output.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nf"&gt;curriedGreet&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Hello&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;John&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Doe&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nf"&gt;curriedGreet&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Hello&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;John&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Doe&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nf"&gt;curriedGreet&lt;/span&gt;&lt;span class="p"&gt;()()(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Hello&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)()(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;John&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)()()()()(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Doe&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Many thanks to &lt;a href="https://medium.com/@_ericelliott" rel="noopener noreferrer"&gt;Eric Elliott&lt;/a&gt; for introducing this to me, and even more thanks to you for appreciating &lt;code&gt;curry&lt;/code&gt; with me. Until next time!&lt;/p&gt;

&lt;p&gt;&lt;em&gt;For more content like this, check out &lt;a href="https://yazeedb.com" rel="noopener noreferrer"&gt;yazeedb.com&lt;/a&gt;!&lt;/em&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>react</category>
      <category>functional</category>
      <category>currying</category>
    </item>
  </channel>
</rss>
