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

283
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

0

do not return because after return goes out of function

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

0

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

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