Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

132
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda