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

303
Views
how to pass argument to multiple lambda expressions in javascript?

can i give 2 argumens if there is multiple lambda funcionts in javascripts? i have the following code

var twice = (x) => {
  return x *x;
}

var lambda = (b) => { 
  (a) =>{
    return b(b(a));
  }
}; 


console.log(lambda(twice, 5));

this wont work, and I could use

  var lambda = (b,a) => { 
        return b(b(a));
    }; 

and will work, but can I use separate lambda expression and give them arguments ?

about 4 years ago · Santiago Trujillo
2 answers
Answer question

0

You can forward arguments to a function like this:

const twice = x => x * x;

const invokeFunctionWithArgs = (fn, ...args) => fn(...args);

console.log(invokeFunctionWithArgs(twice, 5)); // 25

about 4 years ago · Santiago Trujillo Report

0

Yes, You would take advantage of closures so that the inner function returned from invoking lambda() can keep a reference to its surrounding lexical environment.

You then call said inner function with the desired value lambda(twice)(5), in this case, 5.

var twice = (x) => {
  return x *x;
}

var lambda = (b) => { 
  return (a) => {
    return b(b(a));
  }
}; 


console.log( lambda(twice)(5) ); // -> 625

about 4 years ago · Santiago Trujillo 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!