Company logo
  • Jobs
  • Bootcamp
  • About Us
  • For professionals
    • Home
    • Jobs
    • Courses
    • Questions
    • Teachers
    • Bootcamp
  • For business
    • Home
    • Our process
    • Plans
    • Assessments
    • Payroll
    • Blog
    • Calculator

0

56
Views
How can we pass argument to function which itself is passed as argument in javascript
function fun (a, b)  {
        console.log(a + ' ' + b);
        return a == b;
 }

function test(condition) {

    for(let i = 0; i < 1; i++) {
        if(condition()){
            break;
        }
    }
}

How can we pass function fun as an argument inside function test with the argument a and b (a and b are variable). writing test(fun('a', 'b')); is resulting in an error.

7 months ago · Juan Pablo Isaza
1 answers
Answer question

0

You can use a closure like this:

test(function(){ return fun('a', 'b'); });
7 months 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 job Plans Our process Sales
Legal
Terms and conditions Privacy policy
© 2023 PeakU Inc. All Rights Reserved.