Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

112
Views
Currying or closure

Hello I'm doing a javascript coding interview, to prepare for an upcoming one. i had a question that confused me a bit. The question is as follow :

What concept is being illustrated below ?

function makeAdder(x) {
  return function (y) {
    return x + y;
  };
}

var addFive = makeAdder(5);
console.log(addFive(3));

There were 4 answers to pick from and then there's : Currying and Closure

I thought both of these were right. I ended up picking currying, but i really thought this is illustrating closures as well? Could you explain why this is not illustrating closures?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Currying is always a syntax Sugar for closures.It doesn’t call a function. It just transforms it.

For Your above case It's Just Closures because you are taking another variable which stores inner function and executing differently . Like addFive is inner function which is being invoked later.

If you want to to currying it would be like the below example i have created. Currying is the concept of closure, due to its leading exection braces which help inner function executions at same times. So here you don't have to take another variable to store for calling the inner function.

By definition, currying should convert sum(a, b, c) into sum(a)(b)(c).

function makeAdder(x) {
  return function (y) {
    return x + y;
  };
}


console.log(makeAdder(5)(3));

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!