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

281
Visualizações
A function to execute two functions but only one executes?

I have tried using a function to execute two functions when the page loads using window.onload, the issue I am having is that the function (myFunc) only executes the first function from the top (Func1) but not (Func2), the function looks like this

window.onload = function myFunc(){
    return Func1(); 
    return Func2(); 
} 

So how can I execute both of them?

about 4 years ago · Juan Pablo Isaza
3 Respostas
Responde à pergunta

0

Try this :)

make sure you define Functions before calling them, this is good practice

//Arrow function and remove the return

const Func1 = () => {
  console.log('This is Func1');
}
const Func2 = () => {
  console.log('This is Func2');
}

window.onload = myFunc = () => {
  Func1();
  Func2();
}

about 4 years ago · Juan Pablo Isaza Relatório

0

do not return because after return goes out of function

window.onload = function myFunc(){
    Func1(); 
    Func2(); 
}
about 4 years ago · Juan Pablo Isaza Relatório

0

Remove the return keywords, and just run the function as is.

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