Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

198
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!