Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

129
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda