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

127
Views
Javascript - Trigger function return from another function

Is it possible to trigger a function "return" from another function without the explicit keyword?

Example:

let a = function(){

    //Option 1 - Duplicated on function aa
    if(!bb()){
        return false;
    }

    //Option 2 - No check needed as it's delegated on function b
    b(this);
    . . .
}

let aa = function(){

    //Option 1 - Duplicated on function a
    if(!bb()){
        return false;
    }

    //Option 2 - No check needed as it's delegated on function b
    b(this);
    . . .
}

let b = function(fnc){
    if(check)
        fnc.return("hi");
}

let bb = function(){
    if(check)
        return false;
}

a(); //Returns "hi" if condition on function b meets

The problem that I want to solve is avoiding to duplicate the check on each function and avoiding to set the returning value (bool) on the parent function which can be different as it's explicitly defined each time.

What I'm asking is if there's any way to achieve this the way the "pseudo-code" does, with a higher abstraction level.

Thanks.

about 4 years ago · Juan Pablo Isaza
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!