{"id":4050,"date":"2022-09-10T14:41:32","date_gmt":"2022-09-10T19:41:32","guid":{"rendered":"https:\/\/www.becomebetterprogrammer.com\/?p=4050"},"modified":"2022-09-10T14:48:51","modified_gmt":"2022-09-10T19:48:51","slug":"javascript-currying","status":"publish","type":"post","link":"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/javascript-currying\/","title":{"rendered":"A Complete Guide to JavaScript Currying: What Does it Mean?"},"content":{"rendered":"\n<p>Functional programming in Javascript allows you to pass a function as an argument and return a function. This programming style introduces you to several concepts you would also encounter in other programming languages like Python, Erlang, Scala, and many more. They include:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Function currying<\/li><li>Pure and Impure functions<\/li><li>High order functions<\/li><\/ul>\n\n\n\n<p>We already did a blog on &#8220;<a href=\"https:\/\/www.becomebetterprogrammer.com\/javascript-pure-and-impure-functions\/\">Pure and Impure Functions in JavaScript<\/a>.&#8221; This post will focus on currying in Javascript.<\/p>\n\n\n\n<p><strong>Currying is when a function doesn&#8217;t take all its arguments upfront. Instead, you pass the first argument, and the function returns another function that you are supposed to call with the second argument. That will, in turn, return a new function which you will call with the third argument. That goes on and on until you provide all the arguments. The function at the end of the chain will return the value you need.<\/strong><\/p>\n\n\n\n<p>As you might have already seen, currying is an advanced technique for working with Javascript functions &#8211; a concept borrowed from <a href=\"https:\/\/brilliant.org\/wiki\/lambda-calculus\/\" target=\"_blank\" rel=\"noopener\">lambda calculus<\/a>. However, that shouldn&#8217;t scare you, as the implementation is much easier than you imagine. This post will also give you a small &#8220;<a href=\"https:\/\/benalman.com\/news\/2012\/09\/partial-application-in-javascript\/\" target=\"_blank\" rel=\"noopener\">Partial Application<\/a>&#8221; walkthrough to ensure you don&#8217;t confuse it with currying. <\/p>\n\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_82_2 counter-hierarchy ez-toc-counter ez-toc-custom ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\"><p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<\/div><nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/javascript-currying\/#What_is_Currying\" >What is Currying?<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/javascript-currying\/#Currying_in_JavaScript_Example_1\" >Currying in JavaScript: Example 1<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/javascript-currying\/#Currying_in_JavaScript_Example_2\" >Currying in JavaScript: Example 2<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/javascript-currying\/#Currying_in_JavaScript_Example_3\" >Currying in JavaScript: Example 3<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/javascript-currying\/#Why_Currying_Are_there_any_Advantages\" >Why Currying? Are there any Advantages?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/javascript-currying\/#Currying_vs_partial_application\" >Currying vs. partial application<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/javascript-currying\/#Conclusion\" >Conclusion<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"What_is_Currying\"><\/span>What is Currying?<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>First things first\u2014The term &#8220;curry&#8221; in programming is not related to &#8220;curry,&#8221; the food spice. It&#8217;s a technique of transforming functions in Mathematics and Computer Science named after the great American&nbsp;mathematician&nbsp;and&nbsp;logician <a href=\"https:\/\/en.wikipedia.org\/wiki\/Haskell_Curry\" target=\"_blank\" rel=\"noopener\">Haskell Brooks Curry<\/a>.<\/p>\n\n\n\n<p>As described above,<strong> currying transforms a function that takes multiple arguments into a series of nesting functions that return functions that take the subsequent arguments inline. The last function will do the final computation and return the necessary value<\/strong>. <\/p>\n\n\n\n<p>That might sound a little confusing when said in theory. The code snippet below will give you a better understanding.<\/p>\n\n\n\n<pre class=\"wp-block-code language-javascript\"><code>\/\/UNCURRIED FUNCTION\n\/\/Takes 3 arguments and returns the sum of all\n\nfunction addNums (a,b,c){\n  return a + b + c;\n}\nconsole.log(addNums(2,3,4));\n\n\/\/Returns: 9<\/code><\/pre>\n\n\n\n<p>The code snippet above shows a simple function that calculates the sum of three numbers passed as arguments. Let&#8217;s transform it into a curried function.<\/p>\n\n\n\n<pre class=\"wp-block-code language-javascript\"><code>\/\/CURRIED FUNCTION\n\nfunction addNums(a){\n  return function (b){\n    return function(c){\n      return a + b + c\n    }\n  }\n}\n\nconsole.log(addNums(3)(4)(7))\n\/\/Returns: 14<\/code><\/pre>\n\n\n\n<p class=\"language-javascript\">In the code snippet above, the function <code>addNums()<\/code> takes a single argument <code>a<\/code> and returns the second function, which takes the argument <code>b<\/code> , which in turn returns a third function which in turn takes arguments <code>c<\/code>. The third function computes the sum of the three numbers and returns a value.<\/p>\n\n\n\n<p class=\"language-javascript has-vivid-green-cyan-background-color has-background\"><strong>Tip<\/strong>: In programming, <strong><em>arity<\/em> <\/strong>is a term used to refer to the arguments passed in a function. For example, <code>fnOne(a,b)<\/code> is a 2-arity function as it takes two arguments. <code>fnTwo(x,y,z)<\/code> is a 3-arity function as it takes three arguments.<\/p>\n\n\n\n<p>Below are several practicals to help you have a solid understanding of currying in Javascript.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Currying_in_JavaScript_Example_1\"><\/span>Currying in JavaScript: Example 1<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>Take a look at the function below.<\/p>\n\n\n\n<pre class=\"wp-block-code language-javascript\"><code>function sportBike(owner,year,model){\n  return owner +\" rides a \" + year + \" \" + model;\n}\nconsole.log(sportBike(\"John\",2015,\"Kawasaki\"));\n\n\/*Output:\nJohn rides a 2015 Kawasaki\n<\/code><\/pre>\n\n\n\n<p class=\"language-javascript\">In the code above, the <code>sportBike()<\/code> function takes three arguments: owner, year, and model. The function uses string concatenation to form a readable sentence, as seen in the output section. You can use currying to transform this function, as shown below.<\/p>\n\n\n\n<pre class=\"wp-block-code language-javascript\"><code>function sportBike(owner) {\n  return function (year) {\n    return function (model) {\n      return owner + \" rides a \" + year + \" \" + model;\n    };\n  };\n}<\/code><\/pre>\n\n\n\n<p class=\"language-javascript\">In the code above, the <code>sportBike()<\/code> function takes one argument &#8211; <code>owner<\/code> and returns a function. The returned function, in turn, takes one argument &#8211; <code>year<\/code> and also returns another function. The returned function also takes one more argument &#8211; <code>model<\/code> and returns the expected value.<\/p>\n\n\n\n<p class=\"language-javascript\">To call the <code>sportBike()<\/code> function after currying, you will write it as follows:<\/p>\n\n\n\n<pre class=\"wp-block-code language-javascript\"><code>sportBike(\"John\")(2015)(\"Kawasaki\");\n\/*Output:\nJohn rides a 2015 Kawasaki\n<\/code><\/pre>\n\n\n\n<p class=\"language-javascript\">Notice that you are not passing all three arguments in one function this time. Instead, you are using the syntax <code>sportBike()()()<\/code> , which allows you to pass the argument for every function in order. Please note that these arguments are the ones that invoke the functions.<\/p>\n\n\n\n<p class=\"language-javascript\">Therefore, if you used the syntax <code>sportBike()()<\/code>, the last function that returns the final value (string) will not execute.<\/p>\n\n\n\n<p>To keep things clean and neat, you can also use arrow functions to have a more readable code. See the snippet below.<\/p>\n\n\n\n<pre class=\"wp-block-code language-javascript\"><code>const sportBike = (owner) =&gt; (year) =&gt; (model) =&gt; \n      owner + \" rides a \" + year + \" \" + model;\n  \nsportBike(\"John\")(2015)(\"Kawasaki\");\n\n\/*Output:\nJohn rides a 2015 Kawasaki<\/code><\/pre>\n\n\n\n<p>There are situations where you might need to reuse the same value. Instead of invoking a function with the same variable multiple times, you can decide to break the functions as shown below.<\/p>\n\n\n\n<pre class=\"wp-block-code language-javascript\"><code>function sportBike(owner) {\n  return function (year) {\n    return function (model) {\n      return owner + \" rides a \" + year + \" \" + model;\n    };\n  };\n}\n\nlet yearOfManufacture = sportBike(\"John\") \/\/Returns the second functon which expects the argument - year\nlet bikeName = yearOfManufacture(2019) \/\/Returns the third (last) functon which expects the argument - model\n\nconsole.log(bikeName(\"Kawasaki\"))\n\/*Output:\nJohn rides a 2019 Kawasaki\n<\/code><\/pre>\n\n\n\n<p class=\"language-javascript\">So what is happening here? You will notice that there are two new functions in our program &#8211; <code>yearOfManufacture()<\/code> and <code>bikeName()<\/code>. Yes! Those two are indeed functions.<\/p>\n\n\n\n<p class=\"language-javascript\">The <code>yearOfManufacture<\/code> represents the second function in the program. That&#8217;s because it invokes the first function <code>sportBike()<\/code> and passes the first argument &#8211; <code>owner<\/code>. This function will, in turn, return the second function that requires the second argument &#8211; <code>year<\/code>. Therefore, to pass the <code>year<\/code> argument (<em>second argument<\/em>), you will need to invoke the <code>yearOfManufacture<\/code> function.<\/p>\n\n\n\n<p class=\"language-javascript\"><code>bikeName()<\/code> represents the third function in the program. It invokes the <code>yearOfManufacture()<\/code> function that returns a function (<em>third function<\/em>) that takes the <code>model<\/code> argument. That is also the last function in the program and returns the last value &#8211; a string.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Currying_in_JavaScript_Example_2\"><\/span>Currying in JavaScript: Example 2<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>Alternatively, you can write your functions the standard way (<em>without currying<\/em>), then use a library like Lodash to transform them into a curryable function. Take a look at the code snippet below.<\/p>\n\n\n\n<pre class=\"wp-block-code language-javascript\"><code>function addNums(a, b, c) {\n  return console.log(a + b + c);\n}\naddNums(3,4,5)\n\n\/*Output:\n12<\/code><\/pre>\n\n\n\n<p>The code above shows a function, <code>addNums()<\/code>, that takes three arguments and returns the sum. It is a simple standard function without any currying functionalities. To transform <code>addNums()<\/code> to a curryable function, you would write it as follows.<\/p>\n\n\n\n<pre class=\"wp-block-code language-javascript\"><code>let log = console.log;\n\nfunction addNums(a) {\n  return function (b) {\n    return function (c) {\n      return a + b + c;\n    };\n  };\n}\nlog(addNums(3)(4)(5))\n\n\/*Output:\n12<\/code><\/pre>\n\n\n\n<p>Pretty easy, right? If you wish to write less code, you can use a library like Lodash, which automatically transforms your standard function into a curryable one. To start, install the Lodash library using the command below if you are in a NodeJS environment.<\/p>\n\n\n\n<pre class=\"wp-block-code language-javascript\"><code>npm install lodash<\/code><\/pre>\n\n\n\n<p class=\"language-javascript\">After a successful install,  use Lodash to transform the <code>addNums()<\/code> function into a currayble function. See the code below.<\/p>\n\n\n\n<pre class=\"wp-block-code language-javascript\"><code>import _ from \"lodash\"\nlet log = console.log;\n\nfunction addNums(a, b, c) {\n  return console.log(a + b + c);\n}\naddNums = _.curry(addNums)\nlog(addNums(12)(13)(14));\n\n\/*Output:\n39<\/code><\/pre>\n\n\n\n<p class=\"language-javascript\">In the first line, <code>import _ from \"lodash\"<\/code> imports the whole Lodash library to your program. To transform any function into a currayble function using Lodash, use the <code>curry()<\/code> method as shown in the line <code>addNums = _.curry(addNums)<\/code>. <\/p>\n\n\n\n<p class=\"language-javascript\">Quite interesting, right? With one line, you have converted a whole function to a curryable function. The code looks cleaner and is easy to read and debug.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Currying_in_JavaScript_Example_3\"><\/span>Currying in JavaScript: Example 3<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>This section will show you a real-life scenario where you can implement Javascript currying using a library like Lodash. Take a look at the code below.<\/p>\n\n\n\n<pre class=\"wp-block-code language-javascript\"><code>let log = console.log\n\nlet studentCourses = &#91;\n  { student: \"John\", course: \"Computer Science\" },\n  { student: \"Jane\", course: \"Engineering\" },\n  { student: \"Billy\", course: \"Engineering\" },\n  { student: \"Essyy\", course: \"Business Management\" },\n];\n\nlet hasElement = (course, obj) =&gt; obj.course === course\nlet engineeringStudents = studentCourses.filter((x) =&gt; hasElement(\"Engineering\", x));\nlog(engineeringStudents);\n\n\/*Output:\n&#91; { student: 'Jane', course: 'Engineering' },\n  { student: 'Billy', course: 'Engineering' } ]\n<\/code><\/pre>\n\n\n\n<p class=\"language-javascript\">In the code above, you have a <code>studentCourses[]<\/code> array that holds several objects, each with a student name and course. The aim is to have a program that can filter students by their courses.<\/p>\n\n\n\n<p class=\"language-javascript\">The line <code>let engineeringStudents = studentCourses.filter((x) =&gt; hasElement(\"Engineering\", x));<\/code> calls the Javascript filter method on the <code>studentCourses<\/code> array. The filter method takes a callback function that gets every item <code>x<\/code> in the array which is checked against the <code>hasElement()<\/code> function.<\/p>\n\n\n\n<p class=\"language-javascript\">The <code>hasElement()<\/code> function takes two arguments, the element you want to filter and the item fetched from the array. It returns a true or false value. Values that evaluate as true are stored in the <code>engineeringStudents<\/code> variable and later logged in the console.<\/p>\n\n\n\n<p class=\"language-javascript\">You have probably noticed that the <code>hasElement()<\/code> function is not curryable. To make it curryable, you will tweak the code as shown below.<\/p>\n\n\n\n<pre class=\"wp-block-code language-javascript\"><code>function hasElement(course) {\n  return function (obj) {\n    return obj.course === course;\n  };\n}\n\nlet engineeringStudents = studentCourses.filter(hasElement(\"Engineering\"));\nlog(engineeringStudents);\n\n\/*Output:\n&#91; { student: 'Jane', course: 'Engineering' },\n  { student: 'Billy', course: 'Engineering' } ]<\/code><\/pre>\n\n\n\n<p class=\"language-javascript\">But why write all that code when you can use a library like Lodash? To transform the <code>hasElement()<\/code> to a curryable function with Lodash, you would write your code as shown below.<\/p>\n\n\n\n<pre class=\"wp-block-code language-javascript\"><code>let hasElement = _.curry((course, obj) =&gt; obj.course === course)\n\nlet engineeringStudents = studentCourses.filter(hasElement(\"Engineering\"));\nlog(engineeringStudents);\n\n\/*Output:\n&#91; { student: 'Jane', course: 'Engineering' },\n  { student: 'Billy', course: 'Engineering' } ]<\/code><\/pre>\n\n\n\n<p class=\"language-javascript\">Pretty neat and clean, right? The <code>hasElement()<\/code> function is now curryable. That means when you invoke the <code>hasElement()<\/code> and pass &#8220;Engineering,&#8221; as an argument<code>hasElement(\"Engineering\")<\/code>, it will return a new function which in turn expects an argument object to check if it has the course &#8220;Engineering.&#8221; The new function is directly passed as the callback function to the filter method.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Why_Currying_Are_there_any_Advantages\"><\/span>Why Currying? Are there any Advantages?<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Now that you have a better understanding of function currying in Javascript, you might wonder, is there any advantage of currying functions? <\/p>\n\n\n\n<p>Below are some of the currying pros.<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><strong>Function currying allows a program to check if everything is available before moving to the next stage.<\/strong><\/li><li><strong>Currying enables you to avoid invoking a function with the same argument repeatedly.<br><\/strong>Take a look at the code below.<\/li><\/ul>\n\n\n\n<pre class=\"wp-block-code language-javascript\"><code>function itemVolume(l,w,h){\n    return l x w x h;\n}\nitemVolume(50,70,100)\nitemVolume(35,65,100)\nitemVolume(60,40,100)<\/code><\/pre>\n\n\n\n<p class=\"language-javascript\">In the code snippet above, the <code>itemVolume()<\/code> function takes three arguments which it uses to calculate the volume of an item. However, you will notice that if all the items have the same height, you will still need to pass the height value when invoking the function multiple times. You can quickly solve that with currying, as shown below.<\/p>\n\n\n\n<pre class=\"wp-block-code language-javascript\"><code>\nfunction itemVolume(h) {\n  return function (w) {\n    return function (l) {\n        return h * w * l\n    };\n  };\n}\n\nconst itemHeight = itemVolume(100);\nitemHeight(45)(60);\nitemHeight(30)(40);\nitemHeight(65)(75);<\/code><\/pre>\n\n\n\n<p class=\"language-javascript\">The code above does the same thing (calculating volume) but uses function currying. The line <code>const itemHeight = itemVolume(100);<\/code> sets a specific height for all items, and you don&#8217;t have to pass the height value every time you invoke the function.<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><strong>Function currying transforms a function with many responsibilities into smaller functions with a single responsibility each. That results in having pure functions in your code without side effects and less prone to errors.<\/strong><\/li><li><strong>Function currying is used in Javascript to come up with high-order functions.<\/strong><\/li><li><strong>Compared to the standard way of writing functions, function currying, especially when implemented with arrow functions, make your code more readable.<\/strong><\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Currying_vs_partial_application\"><\/span>Currying vs. partial application<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Up to this point, you clearly understand currying in Javascript. However, another concept that confuses most developers as it looks similar to currying is partial application.<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><strong>Currying<\/strong>: As discussed above, currying refers to the process of transforming a single function that takes multiple arguments into a series of nesting functions, each taking a single argument.<\/li><li><strong>Partial application<\/strong>: This refers to a situation where a function is supplied with fewer arguments than it needs and returns a function that takes the remaining arguments.<\/li><\/ul>\n\n\n\n<p>The code snippet below will give you a deeper understanding of partial application.<\/p>\n\n\n\n<pre class=\"wp-block-code language-javascript\"><code>let log = console.log;\nfunction sum(a, b, c) {\n  return a + b + c;\n}\nlog(sum(1,2,3))\n\n\/*Output:\n6<\/code><\/pre>\n\n\n\n<p class=\"language-javascript\"> The <code>sum()<\/code> function above takes three arguments and returns the sum. If you want to implement partial application in the above program, tweak your code as shown below.<\/p>\n\n\n\n<pre class=\"wp-block-code language-javascript\"><code>function sum(a, b, c) {\n  return a + b + c;\n}\n\nfunction partial(fn, ...args) {\n  return function (...moreArgs) {\n    return fn(...args, ...moreArgs);\n  };\n}\n\nconst lastArg = partial(sum, 1,2)\nlog(lastArg(3))\n\n\/*Output:\n6<\/code><\/pre>\n\n\n\n<p><em>What is happening here?<\/em><\/p>\n\n\n\n<p class=\"language-javascript\">First, we write our <code>sum()<\/code> function, which takes three arguments and returns the sum. Next, we will write another function &#8211; <code>function partial(fn, ...args)<\/code> &#8211; that takes a function (fn) as an argument and a list of arguments (&#8230;args). Note that you will use the spread operator here since you are unsure how many arguments will be passed.<\/p>\n\n\n\n<p class=\"language-javascript\">The partial function will return another function &#8211; <code>return function (...moreArgs)<\/code> &#8211; that takes additional arguments (<code>...moreArgs<\/code>). In turn, this function will call the <code>fn<\/code> function and pass all the arguments &#8211; <code>fn(...args, ...moreArgs)<\/code>.<\/p>\n\n\n\n<p class=\"language-javascript\">The line <code>const lastArg = partial(sum, 1,2)<\/code> invokes the <code>sum()<\/code> function partially as you only pass two arguments instead of three (1, 2). The remaining argument is passed in the <code>lastArg()<\/code> function &#8211; <code>lastArg(3)<\/code>.<\/p>\n\n\n\n<p>Even though this might look similar to currying to the naked eye, it is a completely different concept.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Conclusion\"><\/span>Conclusion<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>This post has given you a detailed guide on currying in Javascript. However, if you feel that this currying concept is somehow hard to understand, practice using more examples and also try to implement currying in your projects.<\/p>\n\n\n\n<p>Below are some ideas where you can implement currying when working with Javascript.<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Manipulating the DOM<\/li><li>Working with event listeners<\/li><li>Creating a function that only takes a single argument<\/li><\/ul>\n\n\n\n<p><strong>Was this article helpful? Is there any additional information that you feel was left out?<\/strong><\/p>\n\n\n\n<p>You can also share your thoughts by replying on Twitter of\u00a0<a href=\"https:\/\/twitter.com\/bbprogrammer\/status\/1459150572565798916\" target=\"_blank\" rel=\"noreferrer noopener\">Become A Better Programmer<\/a>\u00a0or to\u00a0<a href=\"https:\/\/twitter.com\/NetmattaTech\" target=\"_blank\" rel=\"noreferrer noopener\">my personal account<\/a>.<\/p>\n\n\n\n<figure class=\"wp-block-embed aligncenter is-type-rich is-provider-twitter wp-block-embed-twitter\"><div class=\"wp-block-embed__wrapper\">\n<blockquote class=\"twitter-tweet\" data-width=\"550\" data-dnt=\"true\"><p lang=\"en\" dir=\"ltr\">We have an article with spices for our <a href=\"https:\/\/twitter.com\/hashtag\/javascript?src=hash&amp;ref_src=twsrc%5Etfw\" target=\"_blank\" rel=\"noopener\">#javascript<\/a> programmers.<br><br>Curry&#8230;&#8230;ing<br><br>Yes, Function currying. Have you heard about it?<br><br>In this article, <a href=\"https:\/\/twitter.com\/NetmattaTech?ref_src=twsrc%5Etfw\" target=\"_blank\" rel=\"noopener\">@NetmattaTech<\/a> explains function currying. Despite what you might think, it doesn&#39;t have to do with food!<a href=\"https:\/\/t.co\/jm8dP9aXDF\">https:\/\/t.co\/jm8dP9aXDF<\/a><\/p>&mdash; Become A Better Programmer (@bbprogrammer) <a href=\"https:\/\/twitter.com\/bbprogrammer\/status\/1568687275525173248?ref_src=twsrc%5Etfw\" target=\"_blank\" rel=\"noopener\">September 10, 2022<\/a><\/blockquote><script async src=\"https:\/\/platform.twitter.com\/widgets.js\" charset=\"utf-8\"><\/script>\n<\/div><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>Functional programming in Javascript allows you to pass a function as an argument and return a function. This programming style introduces you to several concepts you would also encounter in other programming languages like Python, Erlang, Scala, and many more. They include: Function currying Pure and Impure functions High order functions We already did a &#8230; <a title=\"A Complete Guide to JavaScript Currying: What Does it Mean?\" class=\"read-more\" href=\"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/javascript-currying\/\" aria-label=\"More on A Complete Guide to JavaScript Currying: What Does it Mean?\">Read more<\/a><\/p>\n","protected":false},"author":5,"featured_media":4160,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"nf_dc_page":"","_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[16],"tags":[],"class_list":["post-4050","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-javascript","generate-columns","tablet-grid-50","mobile-grid-100","grid-parent","grid-50"],"_links":{"self":[{"href":"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/wp-json\/wp\/v2\/posts\/4050","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/wp-json\/wp\/v2\/comments?post=4050"}],"version-history":[{"count":5,"href":"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/wp-json\/wp\/v2\/posts\/4050\/revisions"}],"predecessor-version":[{"id":4163,"href":"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/wp-json\/wp\/v2\/posts\/4050\/revisions\/4163"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/wp-json\/wp\/v2\/media\/4160"}],"wp:attachment":[{"href":"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/wp-json\/wp\/v2\/media?parent=4050"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/wp-json\/wp\/v2\/categories?post=4050"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/wp-json\/wp\/v2\/tags?post=4050"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}