Karim Aya

Karim Aya


Javascript | Currying VS Partial Application

A lot of people get confused in between currying and partial application and many of us does not know what, where and when we should use them. So this post will cover the practical usage and difference in them.

So lets’s start with definitions


Is a technique for converting function calls with N arguments into chains of N function calls with a single argument for each function call.

Currying always returns another function with only one argument until all of the arguments have been applied. So, we just keep calling the returned function until we’ve exhausted all the arguments and the final value gets returned.

// Normal function
function addition(x, y) {
   return x + y;
// Curried function
function addition(x) {
   return function(y) {
     return x + y;

Note: Curry takes a binary function and returns a unary function that returns a unary function. Its JavaScript code is

function curry(f) {
  return function(x) {
    return function(y) {
       return f(x, y);

Note: A curried functions have a built-in iterator behaviour. One argument is applied at once which is then returned to the calling function to be used for next step. Read here about iterators.


1.   The common use-case for curried function are function composition.e.g., p(x) = q(r(x)). i.e building new function from old function by passing arguments. Function q takes the return value as an argument from function r . Since a function can only return one value, the function being applied to the return value must be unary.

2.   Curried function can also be used while infrastructure setup of a project where there is a lot of possibility to create generic functions thereby little pieces can be configured and reused with ease, without clutter.

3.   Ramda.js lib. functions are automatically curried and lodash has a function called curry which can be used to form curry function.

4.   Memoization is another good use case for curry function.

5.   Handling error throwing functions and exiting immediately after an error.

6.   Catching multiple error and use it as a validator on API’s and client side code.

7.   Can create First class functions which means that we can use functions as arguments and return values. Eg:

const func1 = () => console.log ('Hey Medium.');
const firstClassfunc1 = argsFunc => argsFunc();
const firstClassfunc2 = () => func1;
firstClassfunc1 (firstClassfunc2()); // Hey Medium.

Curry Factory Method(ES6)

const compose = (...fns) =>
  fns.reduce((f, g) => (...args) => f(g(...args)));

Here is a good article on how to make our own curry function factory method using ES5.

Note: Currying in Javascript if not done properly can leads to more complicated stack traces, which is unfortunate for debugging.

Partial Application

Is a technique of fixing a number of arguments to a function, producing another function of smaller arguments i.e binding values to one or more of those arguments as the chain of function progressed.

function add1(x) {
  return 1 + x;

JavaScript has the built-in method .bind that works on functions with any number of arguments and can bind an arbitrary amount of parameters. Its invocation has the following syntax.

function.bind(thisValue, [arg1], [arg2], ...)

It turns function into a new function whose implicit this parameter is this value and whose initial arguments are always as given.

function addition(x, y) {
   return x + y;
const plus5 = addition.bind(null, 5)
plus5(10) // output -> 15

Note: this value does not matter for the (non-method) function addition which is why it is null above.

When using underscore or lodash you can use the partial function which is much nicer than the raw bind method.

Here is a detailed post on partial application and left, right partial application function implementation.


  • Currying always produces nested unary (1-ary) functions. The transformed function is still largely the same as the original.
  • Partial application produces functions of arbitrary number of arguments. The transformed function is different from the original — it needs less arguments.
  • Currying is not partial application. It can be implemented using partial application. You can’t curry a function that takes any number of arguments, (unless you fix the number of arguments).


Easier reuse of more abstract functions which leads to clean code and less complexity which improves code expressive power and maintainability.

If anything is not clear or you want to point out something, please comment down below.

Thanks and Stay tuned for more!


#javascript #web-development

What is GEEK

Buddha Community

Javascript | Currying VS Partial Application

Top 15 Free JavaScript Frameworks for Web Applications

List of some useful JavaScript Frameworks and libraries for website, web apps, and mobile apps development, that developers should know about to make selection easier.
This article will help you understand the various types of JavaScript Framework available in the market. When it comes to choosing the best platform for you, it’s not only the number of features you need to consider but also its functionality. The ease with which it fits within your project is also an essential factor. The next step is to choose the framework that best fits your company requirements or you can select the best from the list of top web development companies to develop your product based on your requirements.

#javascript frameworks for web applications #web applications development companies #progressive javascript framework #javascript frameworks #javascript #frameworks

Samanta  Moore

Samanta Moore


Java Vs. JavaScript: Know the Difference

What a mess it could be to share the same name — especially if you are a programming language. Even if you are already over 20 years old, IT newbies periodically confuse you with your namesake. This happens all the time with Java and JavaScript, although they are not related at all! As someone on the internet said. They correlate in much the same way as a car and a carpet.

Why do these two languages have such similar names? How do they differ from each other, and what else do they have in common? This article will provide the answers to these questions.

In the Beginning, It Was Java

The Same Year, A Little Bit Later: Meet JavaScript!

Technical Differences Between Java and JavaScript

What Can You Build in Java and JavaScript?

#java #javascript #javascript-development #java-development #learn-to-code-java #learn-javascript #programming #java-vs-javascript

Mahipal Nehra

Mahipal Nehra


Java vs. JavaScript: Know The Difference

Java vs. JavaScript

#java #javascript #Java vs. JavaScript #Java vs JavaScript #programming

Rahul Jangid


What is JavaScript - Stackfindover - Blog

Who invented JavaScript, how it works, as we have given information about Programming language in our previous article ( What is PHP ), but today we will talk about what is JavaScript, why JavaScript is used The Answers to all such questions and much other information about JavaScript, you are going to get here today. Hope this information will work for you.

Who invented JavaScript?

JavaScript language was invented by Brendan Eich in 1995. JavaScript is inspired by Java Programming Language. The first name of JavaScript was Mocha which was named by Marc Andreessen, Marc Andreessen is the founder of Netscape and in the same year Mocha was renamed LiveScript, and later in December 1995, it was renamed JavaScript which is still in trend.

What is JavaScript?

JavaScript is a client-side scripting language used with HTML (Hypertext Markup Language). JavaScript is an Interpreted / Oriented language called JS in programming language JavaScript code can be run on any normal web browser. To run the code of JavaScript, we have to enable JavaScript of Web Browser. But some web browsers already have JavaScript enabled.

Today almost all websites are using it as web technology, mind is that there is maximum scope in JavaScript in the coming time, so if you want to become a programmer, then you can be very beneficial to learn JavaScript.

JavaScript Hello World Program

In JavaScript, ‘document.write‘ is used to represent a string on a browser.

<script type="text/javascript">
	document.write("Hello World!");

How to comment JavaScript code?

  • For single line comment in JavaScript we have to use // (double slashes)
  • For multiple line comments we have to use / * – – * /
<script type="text/javascript">

//single line comment

/* document.write("Hello"); */


Advantages and Disadvantages of JavaScript

#javascript #javascript code #javascript hello world #what is javascript #who invented javascript

Hire Dedicated JavaScript Developers -Hire JavaScript Developers

It is said that a digital resource a business has must be interactive in nature, so the website or the business app should be interactive. How do you make the app interactive? With the use of JavaScript.

Does your business need an interactive website or app?

Hire Dedicated JavaScript Developer from WebClues Infotech as the developer we offer is highly skilled and expert in what they do. Our developers are collaborative in nature and work with complete transparency with the customers.

The technology used to develop the overall app by the developers from WebClues Infotech is at par with the latest available technology.

Get your business app with JavaScript

For more inquiry click here https://bit.ly/31eZyDZ

Book Free Interview: https://bit.ly/3dDShFg

#hire dedicated javascript developers #hire javascript developers #top javascript developers for hire #hire javascript developer #hire a freelancer for javascript developer #hire the best javascript developers