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

146
Views
pass arguments to callback function

I want to pass additional parameters to the callback function

function x(logic){
return logic();
}
x(sum, 5, 2);
function sum(){
console.log('sum is ', a + b);
}
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

My problem has resolved with .apply() method

function x(logic, params){
return logic.apply(null, params);
}

let sum = (a, b) => console.log('sum is', a + b);
let sub = (a, b) => console.log('sub is', a - b)
let multi = (a, b) => console.log('multy is', a * b)
let div = (a, b) => console.log('div is', a / b)

x(sum, [7, 5]);
x(sub, [7, 5]);
x(multi, [7, 5]);
x(div, [7, 5]);
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!