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

199
Vistas
Why do we sometimes invoke a function and sometimes not in JS?

This is what confuses me alot: Sometimes we invoke a function and sometimes we do not.

To make this more clear:

We make two functions called getString and makeUpperCase:

function getString(string) {
  return string
}

function makeUpperCase(neutralString) {
  return console.log(getString(neutralString).toUpperCase())
}

makeUpperCase("Books.") // Prints BOOKS.

Here i just made a function called getString, it returns a parameter called string. Then in makeUpperCase function i invoke getString with "Books" as an argument, which will log the argument with UPPERCASE letters. At the end we invoke makeUpperCase function so it will log the text to the console.

Suppose we want to make a promise for an example.

This is just an example:

function executor(resolve, reject) {
  resolve("Promise status: resolved")
}

const promise = new Promise(executor)

I am pretty sure most of the people write promises a different way, however this is how i write the promise.

Here we create the promise, but we do not invoke the function, like we just pass the function executor without invoking it.

Like why? I am not sure if i get the point of sometimes invoking a function and sometimes not. What exactly is the point here?

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