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

105
Vistas
Is callback function essentially a function inside another function?

why is this wrong:

markImportant({ Id: this.row.Id })
          .then(this.showToast("success"))
          .catch(this.showToast("error"));

And this is right?

markImportant({ Id: this.row.Id })
      .then(() => {
          this.showToast("success");
      })
      .catch(() => {
          this.showToast("error");
      });

I'm passing a function as a paremeter in both cases. The first case is only one function, whereas the second function is a function inside another function as a parameter.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

in .then(this.showToast("success")) you are invoking the showToast function which i believe it returns undefined so you can't invoke undefined

in then(() => { this.showToast("success")}) you are passing a function which can be invoked so thats why that works

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